Skip to main content
Google Tag Manager (GTM) captures CTA view and click events on your website, sending them to WisePilot for attribution tracking. This is a critical piece of the optimization pipeline — without GTM events, you can’t track which CTAs are being seen and clicked.

Prerequisites

  • Google Tag Manager account with a container deployed to your website
  • Attribution script already deployed on your site
  • Access to your GTM workspace to create tags and triggers

What GTM Does in the Pipeline

Visitor lands on page → Attribution script sets cr_attrib cookie

Visitor sees a CTA → GTM fires cta_view event with cr_attrib

Visitor clicks a CTA → GTM fires cta_click event with cr_attrib

Events sent to WisePilot → Linked to form submissions via cr_attrib

Step 1: Create CTA View Event Tag

This tag fires when a CTA becomes visible on the page.
  1. In GTM, create a new Custom HTML tag
  2. Set the trigger to a Custom Event named cta_view
  3. Add this HTML:
<script>
  dataLayer.push({
    'event': 'cta_view',
    'event_uuid': '{{Event UUID}}',
    'event_ts_ms': Date.now(),
    'attribution_id': window.getAttributionId ? window.getAttributionId() : null,
    'cta_id': '{{CTA ID}}',
    'cta_position': '{{CTA Position}}',
    'page_path': window.location.pathname,
    'asset_content_id': '{{Asset Content ID}}'
  });
</script>
Replace the {{...}} template variables with actual GTM variables that pull from your CTA data attributes (data-cta-id, data-cta-position, data-asset-content-id).

Step 2: Create CTA Click Event Tag

This tag fires when a user clicks a CTA element.
  1. Create a new Custom HTML tag
  2. Set the trigger to click events on elements with [data-cta-id] or the .cr-cta class
  3. Add this HTML:
<script>
  dataLayer.push({
    'event': 'cta_click',
    'event_uuid': '{{Event UUID}}',
    'event_ts_ms': Date.now(),
    'attribution_id': window.getAttributionId ? window.getAttributionId() : null,
    'cta_id': '{{CTA ID}}',
    'cta_position': '{{CTA Position}}',
    'page_path': window.location.pathname,
    'destination_url': '{{Click URL}}',
    'asset_content_id': '{{Asset Content ID}}'
  });
</script>
For more reliable event delivery, set up a server-side GTM container:
  1. Create or use an existing server-side GTM container
  2. Add a tag that forwards cta_view and cta_click events to:
    https://your-domain.com/api/integrations/gtm/events
    
  3. Include all event parameters in the request payload
Server-side tagging is more reliable than client-side because it avoids ad blockers and browser restrictions.

Step 4: Test Events

Browser Console Test

  1. Visit a page with CTAs on your website
  2. Open browser DevTools → Console
  3. Type dataLayer and press Enter
  4. Look for cta_view and cta_click events in the array
  5. Verify each event has a non-null attribution_id

GTM Preview Mode

  1. In GTM, click Preview to enter debug mode
  2. Visit your website — the GTM debug panel appears
  3. Interact with CTAs
  4. Verify your tags fire on the correct triggers

WisePilot Verification

  1. After generating some events, check the Data Quality Console
  2. The Freshness section should show recent GTM events
  3. The Coverage section should show CTA clicks with attribution

Troubleshooting

Events not arriving in WisePilot

  1. Check GTM container is deployed — View your page source and verify the GTM snippet is present
  2. Check browser console — Look for JavaScript errors that might prevent tags from firing
  3. Check network tab — If using server-side, verify requests to /api/integrations/gtm/events are succeeding (200 status)
  4. Check ad blockers — Some ad blockers prevent GTM from loading. Test in an incognito window with extensions disabled.

Events arrive but attribution_id is null

  1. Verify attribution script loads before GTM — The script must set the cookie before GTM reads it
  2. Check window.getAttributionId() — Open the console and call this function. If it returns null, the attribution script isn’t running.
  3. Check cookies — Look for cr_attrib in Application → Cookies. If missing, the attribution script may be blocked.

Events arrive but CTA fields are empty

  • Verify your CTA elements have the required data attributes: data-cta-id, data-cta-position, data-asset-content-id
  • Check that your GTM variables are correctly reading from these attributes
  • Test with the GTM Preview panel to see what values the variables resolve to