Google Tag Manager
Install EngageTrack via Google Tag Manager.
Google Tag Manager
If your site already uses Google Tag Manager (GTM), you can deploy EngageTrack without touching your site's source code.
1. Create a Custom HTML Tag
- Open your GTM container and go to Tags → New.
- Name the tag EngageTrack Analytics.
- Click Tag Configuration and select Custom HTML.
- Paste the following code:
<script>
(function () {
if (document.querySelector('script[src*="engagetrack"]')) return;
var s = document.createElement("script");
s.defer = true;
s.dataset.siteId = "YOUR_SITE_ID";
s.src = "https://cdn.engagetrack.net/sdk.js";
document.head.appendChild(s);
})();
</script>Replace YOUR_SITE_ID with the Site ID from your EngageTrack dashboard (Site Settings → General).
We create the script dynamically instead of using a static <script>
tag because GTM injects Custom HTML tags into the body. The dynamic approach
ensures the script loads with the correct attributes and avoids duplicate
loading.
2. Set the Trigger
- Click Triggering and select All Pages.
- This fires the tag on every page load, including both the initial load and subsequent navigations.
3. Save and Publish
- Click Save on the tag.
- Use GTM's Preview mode to verify the tag fires correctly.
- Once verified, click Submit to publish the container.
Goal Tracking via GTM DataLayer
You can fire EngageTrack goals based on GTM dataLayer events. For example, if your site pushes events to the dataLayer:
// Your application code
dataLayer.push({
event: "form_submitted",
formName: "contact",
});Create a second Custom HTML tag in GTM to forward these events to EngageTrack:
Step 1: Create a DataLayer Variable
- Go to Variables → User-Defined Variables → New.
- Choose Data Layer Variable.
- Set the variable name to
formName. - Name it DLV - formName and save.
Step 2: Create the Forwarding Tag
- Create a new Custom HTML tag named EngageTrack - Form Goal.
- Paste:
<script>
if (window.engagetrack) {
window.engagetrack("form-submitted", {
form: "{{DLV - formName}}",
});
}
</script>- Set the trigger to a Custom Event with event name
form_submitted. - Save and publish.
Track Revenue via DataLayer
If your e-commerce platform pushes purchase data to the dataLayer:
dataLayer.push({
event: "purchase",
transactionTotal: 99.99,
transactionCurrency: "USD",
});Create a Custom HTML tag to forward revenue:
<script>
if (window.engagetrack && window.engagetrack.trackPurchase) {
window.engagetrack.trackPurchase({
revenue: {{DLV - transactionTotal}},
currency: "{{DLV - transactionCurrency}}",
});
}
</script>Set the trigger to a Custom Event with event name purchase.
Create DataLayer Variables for transactionTotal and transactionCurrency
the same way as described in Step 1 above.
Verify Installation
- Open GTM Preview mode and load your website.
- Confirm the EngageTrack Analytics tag fires on "Container Loaded".
- Navigate between a few pages.
- In the EngageTrack dashboard, go to the Realtime tab — your visits should appear within seconds.
If you see your pageviews in Realtime, you're all set. If not, add
s.dataset.debug = "true" to the script creation code (before
document.head.appendChild) and check the browser console.