Google module
Module id: google. Dependencies: none.
The website's own Google setup, entered per website: Google Analytics 4 and Tag Manager, the shop's e-commerce events for them, site verification for Search Console and Bing, and a Merchant Center product feed. Every theme gets all of it from the shared base layout; nothing has to change in a theme.
The module is off on every website until it is switched on in the Modules tab. Its settings are under Module settings → Google, and can be filled in before the module is switched on.
What operators set
| Setting | What it does |
|---|---|
| GA4 measurement ID | G-…. Loads Google Analytics 4 directly. |
| Tag Manager container ID | GTM-…. Loads the Tag Manager container. |
| Measurement Protocol API secret | Lets the shop send a purchase to GA4 itself when no thank-you page did. See Purchases sent from the server. |
| Google Search Console | Site verification code. |
| Bing Webmaster Tools | Site verification code. |
An ID not shaped like Google's (G- or GTM- plus letters and digits)
is refused on save. A verification field takes the bare code or the whole
<meta> tag as Search Console or Bing hands it out; only the code is
kept, and a Bing tag pasted into the Google field (or the reverse) is
refused with a message saying so.
Fill in one of the two IDs. With Tag Manager, set up GA4 inside the container instead of here, or every visit is counted twice.
Consent
Nothing from Google loads before the visitor allows it on the cookie banner (see cookie consent):
- GA4 loads with Statistics consent.
- Tag Manager loads with either kind, and Google's Consent Mode v2
tells the tags in the container which kinds were given:
analytics_storagefollows Statistics;ad_storage,ad_user_dataandad_personalizationfollow Marketing. - A visitor who has not chosen yet gets the tags the moment they choose, not on the next page: the banner signals the choice and the tags start then, with the page's events.
- Reject all loads nothing and collects nothing.
The verification tags are not affected: they set no cookie and load nothing, so they are on every page whatever the visitor chose.
E-commerce events
The shop pushes Google's recommended e-commerce events (GA4 format) into
the dataLayer, and with GA4 directly also sends them with gtag:
| Event | Where |
|---|---|
view_item_list |
Category, tag and search result pages |
view_item |
Product page |
add_to_cart |
The page the add-to-cart redirects to |
remove_from_cart |
The cart page, after a line is removed or lowered |
view_cart |
Cart page |
begin_checkout |
Checkout page |
purchase |
Thank-you page, once per paid order; else from the server |
Prices are what the shop shows and charges: per unit incl. VAT, the
catalog discount applied. item_id is the product's SKU (a variant's own
SKU when it has one), else its id: the same id the Merchant Center feed
uses, so reports and remarketing tie up.
The purchase is sent once per order: a reload of the thank-you page,
or someone opening a shared link to it, sends nothing. Its value is the
order total incl. VAT and shipping; tax, shipping and a discount
coupon are sent alongside, and transaction_id is the order's id. A
pending order sends nothing until it is paid.
Not sent: add_shipping_info and add_payment_info (checkout is one
page).
Purchases sent from the server
An order whose payment completes after the customer left (a bank payment still pending when they came back, a closed tab, a customer who never returned from the payment page) never shows them the thank-you page, so the browser's tags never see its purchase. With the Measurement Protocol API secret set, the shop sends that purchase to GA4 itself.
- Where the secret comes from: GA4 Admin, Data streams, the website's stream, Measurement Protocol API secrets, Create. Paste the secret value. It is stored encrypted and never shown again; the field says "Stored" and can be replaced or removed.
- Needs the GA4 measurement ID. A site that only has a Tag Manager container gets no server-side purchase.
- When: ten minutes after the payment. A customer who comes back from the payment reaches the thank-you page well before that, and the purchase goes from the browser as usual.
- Once per order: the thank-you page and the server take the same claim, so GA4 gets the purchase from one or the other, never both. A thank-you page opened after the server sent it sends nothing (for the Meta Pixel neither; the Conversions API sends Meta's from the server).
- Consent: only for orders placed by a visitor who allowed
Statistics, and whose browser already had GA4's
_gacookie. At checkout the shop keeps the GA4 client id and session id from those cookies, the IP address (for the location) and whether Marketing was allowed, which sets Consent Mode'sad_user_dataandad_personalization. No consent, nothing kept, nothing sent. - The same purchase: the same
transaction_id, value, tax, shipping, coupon and items as the thank-you page, dated at the payment, in the session the customer paid in. - Not sent: an order refunded or cancelled in those ten minutes, and an order paid more than 72 hours before the worker gets to it (GA4 refuses older events).
Each server send is written to the order's payment events:
ga4_purchase_sent, or ga4_purchase_failed with the reason (the worker
retries). GA4 accepts any well-formed request, also one it then drops, so
"sent" means delivered; check the purchase in GA4's Realtime report or
DebugView.
Merchant Center product feed
With the catalog module on, each language of the website has a product feed Google Merchant Center can fetch on a schedule:
https://<website>/feeds/google-merchant-<locale>.xml
The Google tab lists the URLs. In Merchant Center: Products, Add products from a file, scheduled fetch, one feed per language you sell in.
The feed says what the product page says, from the same code, because Merchant Center compares the two and disapproves a product whose feed disagrees with its page:
- price is the shelf price incl. VAT, with sale_price while a catalog discount runs;
- brand is the product's, else the shop's default brand;
- gtin is the barcode, else the SKU when it is a valid barcode;
without one the item says
identifier_exists: no; - shipping comes from the shipping zones (or the flat rate), per country; returns are left to the Merchant Center account.
One item per product. The product page always opens on the cheapest variant and shows "from", so an item per variant would not match its page. For a product with variants that means the item carries the product's own barcode field, not the variants': the variants' barcodes are in the product page's structured data, one per variant.
Left out: gift cards; products that are not published or not open to everyone; products without a picture or a price; products whose SEO says noindex in that language; and, in a language other than the default, products with no text of their own in it.
The feed 404s while the module or the catalog is off, the site has no host, or the site is set to noindex (still being built). It is cached for an hour.
Themes with Google tags of their own
Some themes load Google tags themselves. Switching the module on for those websites loads them twice. Move the IDs into the module and remove the theme's snippet before switching it on.
Editor previews
The page editor and the designer preview never load the tags: an admin looking at a page is not a visit.
Public routes
| Route | Name | What it does |
|---|---|---|
GET /feeds/google-merchant-{locale}.xml |
cms_google_merchant_feed |
Merchant Center product feed |