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

Cross- domain tracking for eventbrite

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:

  • links from your site to Eventbrite (including mysite.eventbrite.com or www.eventbrite.co.uk)
  • the Universal Analytics tracking code on both your site and your Eventbrite pages.
  • only have one GA tracking code on your own site – or else see the Lunametrics article to cope with this

1. Create a new tag in GTM

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

<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);
</script>

 

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.
Comments 2
  1. Does this work on the eventbrite iframes? The LunaMetrics article says their approach will also append to iframe links. Thanks.

    1. Hi Dan – it should do. If the iframe loads before the tag fire then the links will get decorated. You can delay firing by using another trigger in GTM.

Comments are closed.

Prev
WWI Codebreaking and Interpretation
WWI Codebreaking and Interpretation

WWI Codebreaking and Interpretation

Reading Max Hasting’s excellent book on The Secret War, 1939-1945, I was struck

Next
6 reasons Facebook ads don’t match the data you see in Google Analytics
Facebook ads don't match data in Google Analytics

6 reasons Facebook ads don’t match the data you see in Google Analytics

If you run Facebook Ads and want to see how they perform in Google Analytics,

You May Also Like