Google Analytics · Tag Manager
Measuring across domains and subdomains
Guides on following one visitor across several domains use a site at example-petstore.com whose shop runs on
another domain: a third-party shopping cart at example-commerce-host.com.
Older tracking snippets set the domain in code:
_gaq.push(['_setDomainName', 'example-petstore.com']);
_gaq.push(['_addIgnoredRef', 'example-petstore.com']);
_gaq.push(['_trackPageview']);
These lines belong to Classic Analytics (ga.js). Classic and Universal Analytics no longer collect data.
In Google Analytics 4, cross-domain measurement is set up in the admin rather than in code: Admin, Data streams, your
web stream, Configure tag settings, Configure your domains. Tag Manager setups that fire a tag for
.example-petstore.com need your own domains in the same way.
Structured data · SEO
The sitelinks search box
The best-known example, copied into many themes, plugins and SEO guides:
{
"@context": "https://schema.org",
"@type": "WebSite",
"url": "https://www.example-petstore.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "https://query.example-petstore.com/search?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
Replace url with your home page and target with your own search results page, and keep
{search_term_string} as it is. Google stopped showing the sitelinks search box in November 2024, so the
markup no longer has a visible effect. A WebSite block with your own name and URL still helps with the
site name in search results.
Search Console
Moving a site
Explanations of the Change of Address tool use moves such as http://fish.example-petstore.com
to a new domain, or a subdomain folded into a folder. The tool only works for properties you have verified yourself,
so the example addresses have to be swapped for your own.
APIs · scraping
API and web scraping tutorials
Sample code for API gateways, HTTP clients and scrapers uses a pretend shop:
BASE_URL = "https://api.example-petstore.com/v2"
products = ["https://example-petstore.com/products/grain-free-salmon"]
Requests to these addresses arrive here and get 410 Gone back, with a JSON message saying this is an
example domain. The well-known Swagger Petstore sample API has its own address, petstore.swagger.io.