Structured data
The sitelinks search box and site names
What the search box markup with query.example-petstore.com did, why Google dropped it, and the WebSite markup to use today.
Guide · Google Analytics
Code copied from Google’s Classic Analytics examples still contains example-petstore.com and example-commerce-host.com. It no longer measures anything, and its example links send visitors to the wrong site. This guide replaces it with Google Analytics 4.
From 2009 to 2024, Google’s guide to tracking multiple domains with Classic Analytics (ga.js) used a
pet store at example-petstore.com with a cart at example-commerce-host.com. Typical lines that were copied:
_gaq.push(['_setAccount', 'UA-12345-1']);
_gaq.push(['_setDomainName', 'example-petstore.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setCookiePath', '/myStore/']);
<a href="http://dogs.example-petstore.com/intro.html"
onclick="_gaq.push(['_link', 'http://dogs.example-petstore.com/intro.html']); return false;">See my pet store</a>
<form onSubmit="pageTracker._linkByPost('www.example-commerce-host.com/petStoreCart/begin.php');">
Older variants use pageTracker._setDomainName(".example-petstore.com") with a leading dot, or
_setDomainName("none"). Universal Analytics (analytics.js) code uses
ga('create', …, {'allowLinker': true}) and ga('linker:autoLink', […]) instead.
http://dogs.example-petstore.com/intro.html, take real visitors to the example domain instead of your own pages.href="www.example-petstore.com" is read as a path on your own site and leads to a “not found” page._setDomainName with an example domain never worked on a real site._gaq, pageTracker, urchin, ga.js, analytics.js, ga('create', example-petstore and example-commerce-host.onclick and onsubmit handlers that call _link, _linkByPost or pageTracker./petStoreCart/begin.php) at your own pages or your real checkout, or remove them.Create a Google Analytics 4 property with a web data stream, then add the Google tag to every page, directly or
through Google Tag Manager. Replace G-XXXXXXXXXX with the measurement ID of your stream.
<!-- Google tag (gtag.js) for Google Analytics 4 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
Only needed when one visit spans several of your domains, for example a shop and a checkout provider. In Google Analytics 4 it is set in the admin, not in code:
_gl parameter to links between these domains.In Google Tag Manager, the same list is under Google tags › your tag › Show all. If you prefer code, set the linker domains in the Google tag:
// Only if you configure cross-domain measurement in code instead of in the admin;
// place this before gtag('config', …)
gtag('set', 'linker', {
'domains': ['www.example.com', 'checkout.example.net']
});
A payment provider or other external step can show up as the source of a sale. Add such domains under
Configure tag settings › Show all › List unwanted referrals (up to 50 per stream).
Analytics then ignores these domains as referrers (it adds ignore_referrer=true), so the visit keeps its
original source, such as the ad or search that brought the customer.
ga.js, analytics.js or the example domains._gl= in the destination address.