Cross Domain tracking for Eventbrite using Google Tag Manager (GTM)

by Edward Upton

Cross Domain tracking for Eventbrite using Google Tag Manager (GTM)

Are you using Eventbrite for event registrations? And would you like to see the marketing campaign which drove that event registration correctly attributed in Google Analytics?

Then you’ve come to right place!

Here is a simple guide to adding a Google Tag Manager tag to ensure the correct data is sent to Eventbrite to enable cross-domain tracking with your own website. Many thanks to the Lunametrics blog for their detailed solution, which we have adapted here for GTM.

Before this will work you need to have:

1. Create a new tag in GTM

Create a new custom HTML tag in GTM and paste this script:


(function(document, window) {
 
    //Uses the first GA tracker registered, which is fine for 99.9% of users.
 	
    //won't work for browsers older than IE8
    if (!document.querySelector) return;
 
    var gaName = window.GoogleAnalyticsObject || "ga" ;
 
    // Safely instantiate our GA queue.
    window[gaName]=window[gaName]||function(){(window[gaName].q=window[gaName].q||[]).push(arguments)};window[gaName].l=+new Date;
 
    window[gaName](function() {
        // Defer to the back of the queue if no tracker is ready
        if (!ga.getAll().length) {

          window[gaName](bindUrls);
 
        } else bindUrls();
 
    });
 
    function bindUrls() {
 
      var urls = document.querySelectorAll("a");
      var eventbrite = /eventbrite\./
      var url, i;
 
      for (i = 0; i < urls.length; i++) {
 
        url = urls[i];
 
        if (eventbrite.test(url.hostname) === true) {
          //only fetches clientID if this page has Eventbrite links
          var clientId = getClientId();
          var parameter = "_eboga=" + clientId;

          // If we're in debug mode and can't find a client 
	      if (!clientId) {
	 
	        window.console && window.console.error("GTM Eventbrite Cross Domain: Unable to detect Client ID. Verify you are using Universal Analytics.");
	 		break;
	        return;
	      }
 
          url.search = url.search ? url.search + "&" + parameter : "?" + parameter;
 
        }
 
      }
 
    }
 
    function getClientId() {
      var trackers = window[gaName].getAll();
      return trackers[0].get("clientId");
    }
 
  })(document, window);

2. Set the tag to fire ‘DOM ready’

Create a new trigger (if you don’t have a suitable one) to fire the tag on every page at the DOM ready stage.  We need to make sure the Google Analytics tracker has loaded first.

GTM Cross Domain

3. Test the marketing attribution

With the script working you should see pageviews of the Eventbrite pages as a continuation of the same session.

You can test this by:

  1. Opening the ‘real time’ reporting tag in Google Analytics, on an unfiltered view
  2. Searching for your own site in Google
  3. Navigating to the page with the Eventbrite link and clicking on it
  4. Looking under the Traffic Sources report and checking you are still listed as organic search after viewing the Eventbrite page

Real time traffic sources

Need more help? Comment below or get in touch!

Get Social! Follow us on LinkedIn, Twitter, and Facebook and keep up-to-date with our Google Analytics insights.
Edward Upton
Edward Upton

Founder & CEO

Edward founded Littledata in 2015 as an analytics consultancy for ecommerce brands including MADE.COM and Micro Scooters, then turned it into the data layer for Shopify. He has spent over a decade on Shopify tracking, GA4 and marketing attribution, and speaks on ecommerce analytics at events including DigiMarCon and the Ecommerce Agency Summit.