
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@dotcms/analytics
Advanced tools
Official JavaScript library for Content Analytics with DotCMS.
@dotcms/analytics
is the official dotCMS JavaScript library for Content Analytics that helps track events and analytics in your webapps. Available for both browser and React applications.
npm install @dotcms/analytics
Or include the script in your HTML page:
<script src="ca.min.js"></script>
First, import the provider:
import { DotContentAnalyticsProvider } from '@dotcms/analytics/react';
Wrap your application with the DotContentAnalyticsProvider
:
// Example configuration
const analyticsConfig = {
apiKey: 'your-api-key-from-dotcms-analytics-app',
server: 'https://your-dotcms-instance.com'
};
function App() {
return (
<DotContentAnalyticsProvider config={analyticsConfig}>
<YourApp />
</DotContentAnalyticsProvider>
);
}
Use the useContentAnalytics
hook to track custom events:
import { useContentAnalytics } from '@dotcms/analytics/react';
function Activity({ title, urlTitle }) {
const { track } = useContentAnalytics();
// First parameter: custom event name to identify the action
// Second parameter: object with properties you want to track
return <button onClick={() => track('btn-click', { title, urlTitle })}>See Details →</button>;
}
To manually track page views, first disable automatic tracking in your config:
const analyticsConfig = {
apiKey: 'your-api-key-from-dotcms-analytics-app',
server: 'https://your-dotcms-instance.com',
autoPageView: false // Disable automatic tracking
};
Then use the useContentAnalytics
hook in your layout component:
import { useContentAnalytics } from '@dotcms/analytics/react';
function Layout({ children }) {
const { pageView } = useContentAnalytics();
useEffect(() => {
pageView({
// Add any custom properties you want to track
myCustomValue: '2'
});
}, []);
return <div>{children}</div>;
}
The script can be configured using data attributes:
<!-- Example configuration -->
<script
src="ca.min.js"
data-analytics-server="http://localhost:8080"
data-analytics-key="dev-key-123"
data-analytics-auto-page-view
data-analytics-debug></script>
<!-- Without automatic tracking - events must be sent manually -->
<script
src="ca.min.js"
data-analytics-server="http://localhost:8080"
data-analytics-debug
data-analytics-key="dev-key-123"></script>
The following features are planned for future releases:
GitHub pull requests are the preferred method to contribute code to dotCMS. Before any pull requests can be accepted, an automated tool will ask you to agree to the dotCMS Contributor's Agreement.
dotCMS comes in multiple editions and as such is dual licensed. The dotCMS Community Edition is licensed under the GPL 3.0 and is freely available for download, customization and deployment for use within organizations of all stripes. dotCMS Enterprise Editions (EE) adds a number of enterprise features and is available via a supported, indemnified commercial license from dotCMS. For the differences between the editions, see the feature page.
If you need help or have any questions, please open an issue in the GitHub repository.
Always refer to the official DotCMS documentation for comprehensive guides and API references.
Source | Location |
---|---|
Installation | Installation |
Documentation | Documentation |
Videos | Helpful Videos |
Forums/Listserv | via Google Groups |
@dotCMS | |
Main Site | dotCMS.com |
FAQs
Official JavaScript library for Content Analytics with DotCMS.
The npm package @dotcms/analytics receives a total of 32 weekly downloads. As such, @dotcms/analytics popularity was classified as not popular.
We found that @dotcms/analytics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.