// We want to track some custom dimensions on the event pages // For that, we first check if we are in an event page var isEvent = document.location.pathname.match('^/e\//*'), isNewListing, eventPublicId; // TODO: move these dimensions to the event pages instead of checking on every page. if(isEvent){ eventPublicId = 1480658020999 // Check if the request comes from Youtube (utm_source and utm_medium should be checked). // Setting the value of eb_youtube_events in localstorage to be able to track ecommerce conversions if (RegExp('[?&]utm_(source|medium)=Youtube([&#].*)?$', 'i').test(document.location.search)) { var localStorageKey = 'eb_youtube_events', eventsToLogString = localStorage.getItem(localStorageKey), publicIdAsString = eventPublicId.toString(), eventsToLog = []; if (eventsToLogString) { eventsToLog = JSON.parse(eventsToLogString); } if(eventsToLog.indexOf(publicIdAsString) === -1) { eventsToLog.push(publicIdAsString); } localStorage.setItem(localStorageKey, JSON.stringify(eventsToLog)); } } function initAnalytics(EBAnalytics) { var eventOwnerUserId, eventSource, dimensions = [ EBAnalytics.DIMENSIONS.USER_ID(null), EBAnalytics.DIMENSIONS.GUEST_ID(null), EBAnalytics.DIMENSIONS.EVENT_ID(eventPublicId), EBAnalytics.DIMENSIONS.EXPERIMENT_ID(isNewListing ? 'NewListing' : 'OldListing'), EBAnalytics.DIMENSIONS.URL_PARAMS(location.search) ]; EBAnalytics.setInternalUseGACookie(); EBAnalytics.trackPendingInternalLink('ebEventToTrack'); eventOwnerUserId = 2168378109 dimensions.push(EBAnalytics.DIMENSIONS.EVENT_OWNER_USER_ID(eventOwnerUserId)); if (isEvent) { eventSource = 'Eventbrite' dimensions.push(EBAnalytics.DIMENSIONS.EVENT_SOURCE(eventSource)); } EBAnalytics.addDimensions(dimensions); } if (typeof(require) !== 'undefined') { require(['mediatorjs', 'eb/analytics'], function(mediatorjs, Analytics) { initAnalytics(Analytics); Analytics.trackPageView(mediatorjs.get('GAPageviewProperties') || {}); }); } else if (window.EB && window.EB.Analytics) { initAnalytics(window.EB.Analytics); window.EB.Analytics.trackPageView({}); } else { // This is for pages that don't have require (ie our widgets) ga('send', 'pageview'); }