Cross-domain measurement enables two or more related sites on separate domains to be measured as one.
There are two cases where you will need to set up Cross Domain Tracking:
- Handling Redirects: If your website is redirecting people directly to showpass.com to purchase tickets
- Using the Purchase Widget: If you are using the Showpass Purchase Widget to sell tickets directly on your website.
Handling Redirects
For tracking redirects across domains, configuration can now be done on the Google Analytics 4 admin dashboard with no-code changes required:
- In GA4 Admin, click Data Streams in the Property column.
- Click Web and then click a web data stream.
- In the web stream details, click Configure tag settings (at the bottom).
- In the Settings section, click Configure your domains.
- Under Include domains that match ANY of the following conditions:
-
- Choose a match type.
- Under Domain, enter the identifier for the domain you want to match (e.g., example.com).
- Click Add condition to add the next domain. (Add each domain you want to include in cross-domain measurement.)
- Conditions are evaluated using OR logic.
- Click Save.
Using the Purchase Widget
Wordpress Ready
If you are using our Wordpress Plugin, you DO NOT need to manually add the following code, our plugin automatically handles cross domain tracking for widgets. Please ensure you are on version 3.8.1 or higher of our Wordpress plugin
For tracking sessions across domains using the purchase widget, you will need to access to your site's code and add the following JavaScript code:
<script type="text/javascript">
/**
* Shared function to decorate iframe - we default to cookie version because its more reliable
* @param {object} showpass widget iframe object
*/
const decorateIframe = (iFrame) = {
// For analytics.js (UA)
// We use the linker provided by analytics.js to decorate the iframe src
let gobj = window[window.GoogleAnalyticsObject];
if (gobj) {
let tracker = gobj.getAll()[0];
let linker = new window.gaplugins.Linker(tracker);
iFrame.src = linker.decorate(iFrame.src);
}
if (typeof document.cookie === 'string' && document.cookie !== '') {
// Get the _ga from cookies and parse it to extract client_id and session_id.
// This is used as a fallback for GTM implementations.
let cookie = {};
document.cookie.split(';').forEach(function(el) {
const splitCookie = el.split('=');
const key = splitCookie[0].trim();
const value = splitCookie[1];
cookie[key] = value;
});
// Parse the _ga cookie to extract client_id and session_id.
// A _ga cookie will look something like GA1.1.1194072907.1685136322
const gaCookie = cookie["_ga"];
if (gaCookie) {
const client_id = gaCookie.substring(6); // using the example above, this will return "1194072907.1685136322"
const session_id = client_id.split(".")[1]; // ["1194072907", "1685136322"]
if (!isNaN(Number(client_id)) && !isNaN(Number(session_id))) {
let url = new URL(iFrame.src);
url.searchParams.append('client_id', client_id);
url.searchParams.append('session_id', session_id);
iFrame.src = url.toString();
}
}
}
}
/*
* Decorate iFrame for GA cross domain tracking
* This only works for pop ups, for embedded calendar we need to use a watcher
*/
const mutationObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.target.className.includes('showpass-widget-body') && document) {
let iFrame = document.getElementById('showpass-widget');
// if query params already exist, exit
let queryParams = new URLSearchParams(iFrame.src);
if (queryParams.get('client_id') || queryParams.get('session_id')) {
return;
}
decorateIframe(iFrame);
}
});
});
mutationObserver.observe(document.documentElement, { attributes: true });
/** Wrap iFrame for embedded calendar */
let calendarDIV = document.getElementById("showpass-calendar-widget");
if (calendarDIV) {
function wrapIFrame(iFrame) {
clearInterval(findIFrameInterval);
decorateIframe(iFrame);
}
const findIFrameInterval = setInterval(findIFrame, 100);
function findIFrame() {
let iFrame = document.getElementsByClassName("showpass-widget-iframe");
if (iFrame && iFrame[0] && iFrame[0].src) {
wrapIFrame(iFrame[0]);
}
}
</script>
Referral Exclusion lists in Google Analytics 4
In contrast to Universal Analytics, you no longer have to configure a Referral Exclusion when cross-domain measurement is configured. Click here to learn more!