Skip to main content

Set Up Conversion Tracking with the Exerta Tracking SDK

Written by Elaine De Guzman

The Exerta Tracking SDK is a JavaScript library that helps you implement conversion tracking in Exerta without using additional tracking tools.


💡 Why use this?

The SDK lets you track conversions in Exerta without using additional tracking tools. You can add it directly to your HTML pages or use Google Tag Manager (GTM). Each time a purchase is completed, a conversion is sent to Exerta.

This helps our AI also learn from the messages that are converting so it can double-down on that.


🛠️ How to use this?

Pick the setup that matches your funnel:

  • Direct implementation: you don't use tracking tools or Google Tag Manager for your funnel

  • GTM without a DataLayer: you don't use tracking tools but use Google Tag Manager, and your store does not push purchase events into the DataLayer automatically

  • GTM with the DataLayer: you don't use tracking tools but use Google Tag Manager, and your e-commerce platform (Shopify, WooCommerce, Magento, etc.) already pushes a purchase event into the GTM DataLayer

💡 Tip: The snippets below are examples. You can find your specific snippet on your account's tracking page.


🔧 Direct implementation

When to use this: if you don't use tracking tools or Google Tag Manager for your funnel.

  1. Add the following HTML tag to every page of your funnel:

<script src="https://app.exerta.ai/exerta.sdk.js"></script>
<script>
ExertaSdk.init({
endpoint: "https://api.reengage.ai/postback/example/"
});
</script>

2. On your order confirmation or "thank you" page, add the following snippet. This fires once a purchase is completed. Replace the values with your actual order data from your platform.

<script>
ExertaSdk.track({revenue: 100.00, currency: "EUR"});
</script>

This sends a conversion with the value of 100 EUR to Exerta.

💡 Tip: The currency parameter is optional and is USD by default.


🏷️ Google Tag Manager without a DataLayer

When to use this: if you don't use tracking tools but use Google Tag Manager for your funnel.

Best if your site already has GTM installed and you want to manage the SDK from the GTM interface, but your store does not push purchase events into the DataLayer automatically.

  1. Create a Custom HTML tag named ExertaSdk.

  2. Copy the following code into the HTML field and save the tag:

<script src="https://app.exerta.ai/exerta.sdk.js"></script>
<script>
ExertaSdk.init({
endpoint: "https://api.reengage.ai/postback/example/"
});
</script>

3. Select All Pages - Page View as the trigger. This ensures the SDK loads on every page.

4. Create a second Custom HTML tag for conversions. Use the following code in the HTML field:

<script src="https://app.exerta.ai/exerta.sdk.js"></script>
<script>
ExertaSdk.init({
endpoint: "https://api.reengage.ai/postback/example/"
});
</script>

📋 Note: {{Order Total}} and {{Order Currency}} are GTM variables. You'll need to create these in GTM > Variables, pointing to where your platform stores the order value (could be a cookie, URL parameter, or custom JavaScript variable). Ask your developer for the correct variable sources.

5. Set this tag's trigger to fire on your order confirmation event or thank-you page.

6. Click Submit in the top-right of GTM and publish the container.

⚠️ Important: Changes won't go live until you publish the container.


🤖 Google Tag Manager with the DataLayer

When to use this: if you don't use tracking tools but use Google Tag Manager for your funnel. Best if your e-commerce platform (Shopify, WooCommerce, Magento, etc.) already pushes a purchase event into the GTM DataLayer. The SDK detects it automatically, so no extra conversion tag is needed.

Step 1: Confirm your platform uses the DataLayer

Most modern e-commerce platforms push purchase events automatically. Your platform must use the standard GA4 DataLayer purchase event, with the value parameter used for the purchase total value.

If you use a thank-you page to send conversions, you can check this:

  1. Open your thank-you page.

  2. Open your browser's developer console.

  3. Type:

dataLayer.filter(e => e.event === "purchase")

If you see an object with an ecommerce block containing a value and currency, your platform is already set up correctly.

Step 2: Create a single Init tag in GTM

This is the only tag you need.

  1. Create a Custom HTML tag named ExertaSDK.

  2. Copy the following code into the HTML field and save the tag:

<script src="https://app.exerta.ai/exerta.sdk.js"></script> <script>   ExertaSdk.init({     endpoint: "https://api.reengage.ai/postback/example/"   }); </script>

3. Select All Pages - Page View as the trigger. This ensures the SDK loads on every page.

That's it. The SDK listens to the DataLayer automatically. When your platform pushes a purchase event, the SDK captures the revenue and currency without any additional tags or configuration.


📚 SDK reference

A summary of every available SDK call, for your developer.

Methods

Method

What it does

Required?

ExertaSdk.init(options)

Must be called first on every page. Sets the endpoint URL and configuration.

Required

ExertaSdk.track(data)

Tracks any custom event. First argument is a name you choose; second is an optional object with extra data.

Required

Init options

Option

What it controls

Default

endpoint

The URL where tracking events are sent. Provided by your tracking specialist.

Required

cookieDays

How many days to remember a visitor's attribution cookie.

30

debug

When set to true, logs all SDK activity to the browser console. Turn off in production.

false

overwriteExisting

If a visitor already has an attribution ID stored and arrives via a new tracking link, should the old ID be replaced?

true

cookieDomain

Set this if you need the tracking cookie to work across subdomains (e.g. .yourdomain.com).

Current domain

⚠️ Important: The SDK only sends data for visitors who arrived via a tracked link (containing a reid parameter). Visitors without this parameter are ignored. This is by design, to ensure accurate attribution.


❓ FAQs

🔍 Q: Where do I find my specific SDK snippet?
A: In your dashboard. The snippets in this guide are examples.


⚠️ Q: Why isn't the SDK sending data for some of my visitors?
A: The SDK only sends data for visitors who arrived via a tracked link containing a reid parameter. Visitors without this parameter are ignored by design, to ensure accurate attribution.


📋 Q: Do I have to set the currency?
A: No. The currency parameter is optional and is USD by default.


📋 Q: Which Google Tag Manager setup should I use?
A: It depends on your platform:

  • If your store does not push purchase events into the DataLayer automatically, use GTM without a DataLayer

  • If your e-commerce platform (Shopify, WooCommerce, Magento, etc.) already pushes a purchase event into the DataLayer, use GTM with the DataLayer


🔍 Q: Do I need a conversion tag if I use the DataLayer setup?
A: No. The SDK detects the purchase event automatically. No extra conversion tag is needed.


⚠️ Q: I published my GTM changes but nothing is live. Why?
A: Changes won't go live until you click Submit in the top-right of GTM and publish the container.


🔍 Q: How do I check that my platform pushes the DataLayer purchase event?
A: Open your thank-you page, open your browser's developer console, and type dataLayer.filter(e => e.event === "purchase"). If you see an object with an ecommerce block containing a value and currency, your platform is set up correctly.


📋 Q: How can I see what the SDK is doing?
A: Set debug to true in ExertaSdk.init. The SDK then logs all its activity to the browser console. Turn it off in production.


🔍 Q: How long does the SDK remember a visitor?
A: 30 days by default. You can change this with the cookieDays option.

Did this answer your question?