Skip to main content

Google Tag Manager

Updated this week

Google Tag Manager (GTM) lets you manage tags and JavaScript snippets (like those for Intempt) without needing developer help.

Step 1: Navigate to the “Tags” section of your GTM account, and click “New” to create a new tag:

Step 2: Give your tag a name, like “Intempt”, then edit the Tag configuration:

Step 3: Search for “Custom HTML” and select it as the tag type:

Step 4: Create your source, click in the “Snippet” text box, and paste the snippet from your project definition page in Intempt:

To create a source, you should open the Integrations section -> Sources tab in the Intempt console and click on the "Create source" button:

And choose the Web source:

After creation, you’ll be taken to the "Website Tracking" page. The next step is to copy the script tag’s src attribute value:

Here we use the copied value to load the SDK script tag after the gtag script in the HTML

JavaScript

(function () {
try {
var head = document.head || document.getElementsByTagName('head')[0];
var gtagScripts = head.querySelectorAll('script[src^="https://www.googletagmanager.com/gtag/js"]');
var gtagScript = gtagScripts.length ? gtagScripts[gtagScripts.length - 1] : null;
// Create your Intempt script
var s = document.createElement('script');
s.src = https://cdn.intempt.com/v1/intempt.min.js?organization=YOUR_ORGANIZATION&project=YOUR_PROJECT&source=YOUR_SOURCE_ID&key=YOUR_API_KEY;
s.async = true;
if (gtagScript && gtagScript.parentNode) {
// Insert immediately after the gtag script
gtagScript.parentNode.insertBefore(s, gtagScript.nextSibling);
} else {
// Fallback: put it at end of <head>
head.appendChild(s);
}
} catch (e) {
console.warn('Intempt inject error', e);
}
})();

🚧 The snippet for the script tag loader can be changed; however, make sure that the SDK script tag loads as early as possible during your website’s loading process.

Paste the snippet for the SDK script tag loader here:

🚧 Make sure your JS snippet is included as an inline <script> tag in the HTML.

Step 5: Create and paste your Intempt project API key:

To create a new API key, you should open the API Keys section and click on "Create public key":

Enter a key name:

After creation, copy your generated key:

And paste into your snippet in GTM instead of the "YOUR_API_KEY" placeholder:

Step 6: Now add a trigger for “All Pages: Page View”:

Step 7: Next, click “Save” and "Submit" to publish your changes:

Did this answer your question?