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.0 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">
/*
* Decorate iFrame for GA cross domain tracking
*/
const mutationObserver = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.target.className.includes("showpass-widget-body")) {
let iFrame = document.getElementById("showpass-widget");
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 (window.gtag && window.dataLayer) {
let ga4Config = window.dataLayer.find(x => x[0] === "config" && x[1].startsWith("G-"));
let ga4Id = ga4Config[1];
let url = new URL(iFrame.src);
window.gtag("get", ga4Id, "client_id", client_id => {
window.gtag("get", ga4Id, "session_id", session_id => {
try {
url.searchParams.append("client_id", client_id);
url.searchParams.append("session_id", session_id);
iFrame.src = url.toString();
} catch (e) {
console.error(e);
}
});
});
}
}
});
});
mutationObserver.observe(document.documentElement, { attributes: true });
</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!