Install the Pixel on your website
Copy the dashboard snippet, publish it, and prepare JavaScript calls.
Install the Pixel once to measure events configured in CJM. You need a created Pixel and access to edit and publish your website.
Installation
- Open Setup → Pixels, select your Pixel, and go to Installation & test.
- On the HTML tab, copy the entire Tracking script snippet.
- Insert it in the shared website header before
</head>on the pages you want to measure. - Save and publish. Publish or clear any website cache as needed.
- Connect your cookie banner.
- Open the published website and verify installation.
The snippet has this shape; replace both placeholders with the values copied from the dashboard:
<script async src="URL_DELLO_SCRIPT_COPIATO_DA_CJM" data-site-key="CHIAVE_COPIATA_DA_CJM"></script>Do not substitute the Pixel ID or shortened key preview for data-site-key. No init() call is needed. Do not install the same Pixel both directly and through GTM.
Where to install
| Website | Action |
|---|---|
| HTML | Insert the snippet in the shared header. |
| WordPress or another CMS | Use your website's header code feature; publish on all relevant pages. |
| React | Insert it in the initial HTML document. Do not reinstall on each route change. |
| Next.js | Ask your developer to use next/script with strategy="afterInteractive", preserving src and data-site-key. Use onLoad in a client component for initial integration calls. |
| GTM already installed | Follow the GTM guide. |
Before calling the APIs
async allows the script to load after subsequent page code. The internal queue exists only once window.CJMPixel is available. It cannot protect calls made before the download finishes.
To initialize an integration after loading, use this pattern at the bottom of the page, after the copied snippet:
function connectCjm() {
// Connect handlers for the form or banner already installed on your website.
}
if (window.CJMPixel) {
connectCjm();
} else {
const script = document.querySelector('script[data-site-key]');
script?.addEventListener('load', connectCjm, { once: true });
script?.addEventListener('error', () => {
console.error('CJM: script loading failed');
}, { once: true });
}After loading, write calls automatically wait for configuration. If configuration cannot load and no usable cached copy exists, tracking does not start. Events still waiting when the visitor leaves may be lost.
Update events
With the current snippet, you do not need to paste the code again after changing dashboard settings. Reload the website: the Pixel refreshes configuration, temporarily using a recent session copy when available. An already open page does not continuously receive updates.
For installations predating remote configuration, replace the old code with the current snippet from Installation & test → HTML.
Advanced configuration: what not to add to the snippet
The public snippet requires only src and data-site-key. Developers may also encounter these fields in the Pixel contract; they are not track arguments and adding script attributes does not activate them.
| Field | Effect and limitation |
|---|---|
siteKey, baseUrl, events | Key, collection address, and event configuration resolved by remote loading. Manage events in the dashboard. |
features | The four Automatic tracking switches in Settings. |
cookieDomain | Cookie domain compatible with the website host; separate from the collection domain. No dedicated field in the current event editor. |
serverSideTracking.googleAnalytics, serverSideTracking.meta | Enable collection of integration advertising identifiers with the required consent. They do not install tags or create server rules. |
debug | Additional console diagnostics; switch in Settings → Advanced delivery. |
disabled | Prevents tracking activation; separate from the four Automatic tracking switches. |
version | Diagnostic version label for technical initialization. |
hubspot.selectors, ghl.selectors, ghl.submitMessageMatchers | Technical contract extensions not included in the current snippet's remote configuration. See embedded form limitations. |
The exported CJMPixel class is for technical integrations managing an instance; it is not a second procedure to run alongside the snippet. For dashboard installation, use the documented window.CJMPixel functions.