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.
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:
- Opening the ‘real time’ reporting tag in Google Analytics, on an unfiltered view
- Searching for your own site in Google
- Navigating to the page with the Eventbrite link and clicking on it
- Looking under the Traffic Sources report and checking you are still listed as organic search after viewing the Eventbrite page
Need more help? Comment below or get in touch!
Does this work on the eventbrite iframes? The LunaMetrics article says their approach will also append to iframe links. Thanks.
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.