Google Tag - usersaynoso/cactus-foundation GitHub Wiki
Google Tag
Puts the Google tag on your site so Google Analytics and Google Ads can tell you what your visitors did - and, when someone buys something, what the order was worth. It is how you find out which adverts pay for themselves rather than guessing.
It works on any site for visitor numbers. Add the Shop module and it counts the sales too.
What you need before you start
Depending on what you want to measure, one or both of:
- A Google Analytics measurement ID. In Google Analytics: Admin → Data streams → your website. It looks like
G-XXXXXXXXXX. - A Google Ads conversion ID and conversion label. In Google Ads: Goals → Conversions → your purchase action. Google shows them as a pair, like
AW-123456789andabcDE_fgHijklMN. You need both. The ID says which account; the label says which conversion. An ID on its own counts nothing.
You can paste the whole thing Google gives you into either box - the two halves are pulled apart for you.
Setting it up
- Install the module.
- Go to Settings → General → Google Tag.
- Paste in whichever IDs you have.
- Tick Send measurements to Google.
- The Google Tag block goes onto your header layout on its own when you install the module. It shows nothing on the page - it just does the counting. Move it or delete it if you would rather, and it stays moved or deleted; nothing puts it back. If you installed the module before this was automatic, add it yourself: Layouts → your header layout → Google Tag. Without it, nothing is measured at all.
- Sort your cookie banner out. See below. The settings page will tell you if something is amiss.
Settings
| Setting | What it does |
|---|---|
| Send measurements to Google | The master switch. Off, nothing is sent whatever else is filled in. |
| Google Analytics measurement ID | Your G-… ID. Leave empty if you only want to measure adverts. |
| Google Ads conversion ID | Your AW-… ID. Leave empty if you only want visitor numbers. |
| Google Ads conversion label | The other half of the pair. Without it, Google Ads will not count your orders. |
| What a sale is worth to Google Ads | Whether a sale is reported to Google Ads at the full order total, the total without VAT, or the total without VAT or delivery. See What a sale is worth below. Affects Google Ads only. |
| Count page views as well as orders | On, Analytics gets every page a visitor looks at. Off, only orders are reported. |
| Let Google estimate the visitors who said no | See Consent below. Off by default, which is the cautious setting. |
Consent
Nothing here happens behind your visitors' backs. The tag runs on the same cookie banner as the rest of your site, and a visitor who changes their mind is honoured on the spot - no reload, no waiting.
Two of the standard cookie categories cover it:
| Category | Covers |
|---|---|
| Analytics | Counting visits and pages. No advertising. |
| Marketing | Measuring which advert led to an order, and showing relevant adverts elsewhere. |
Both come with a Cactus cookie banner as standard. If yours is missing one, the module offers it as a one-click suggestion on Settings → Privacy, with the wording already written - hover it to read the wording, click it to add it, then save.
The bit worth reading twice
You can only wait for a switch that exists. If your banner has no Analytics category, there is nothing for a visitor to agree to - so rather than wait for ever and quietly measure nothing while appearing to be switched on, the tag runs for everybody. Same for Marketing.
That may be exactly what you want, or it may be an oversight. The Google Tag settings page tells you which situation you are in, in plain English, with a link straight to the Privacy settings. It also warns you if your cookie banner is switched off altogether, in which case nobody is asked anything at all.
Getting this right is your responsibility, not the module's. It just refuses to be quiet about it.
"Let Google estimate the visitors who said no"
Google's consent system has two honest readings, and this switch picks between them.
- Off (the default). Nothing Google-related is fetched at all until a visitor agrees. Someone who has not answered your banner, or who said no, has no contact with Google whatsoever. Cleanest to explain; you simply see fewer visitors than you had.
- On. Google is loaded straight away but told it may not store anything about the visitor. It sends anonymous, cookieless pings, which it uses to estimate the visits it is not allowed to measure properly. Better numbers, rather more to explain if anyone ever asks.
What gets measured
Page views (if you have left that on): the page someone landed on, and each page they move to afterwards.
Orders. When an order reaches the confirmation page, Google is told the order number, the total, the tax, the delivery, any discount code, and every line on the order. What Google Ads counts the sale as worth can be the total or the total less VAT - see What a sale is worth.
An order counts when it is paid, or when it has been placed on a manual payment method - a bank transfer or cash - and is waiting for the money. That second case is deliberate: a good deal of trade ordering works that way, and leaving those out would make your shop look half the size it is. A payment that is still going through, or one that failed, is nobody's sale and is not counted.
An order is only ever counted once, however many times the confirmation page is refreshed, revisited or bookmarked and come back to next week.
What a sale is worth
When an order is placed, Google Ads is told what it was worth, and that one figure is what every return-on-spend number in your account is built on.
By default it is the full order total, as the customer paid it. For most shops that is right and there is nothing to think about.
If you quote your prices without VAT, it is not right. The total on the order still has the VAT on top, but the VAT was never yours - it goes to HMRC. Report it to Google and every return-on-spend figure in the account reads high by the VAT rate. On a thin margin that matters rather a lot: a shop working on 6% needs to take about 18 pounds for every pound of advertising to break even, but an account measuring VAT-inclusive sales thinks it is already taking 21. Worse, if you have given Google a target to bid towards, it is quietly bidding 20% looser than you told it to, for ever, and nothing anywhere says so.
So there are three choices:
| Choice | What Google Ads is told a sale was worth |
|---|---|
| The full order total, as the customer paid it | Everything on the order, VAT and delivery included. The default, and what this module always did before the setting existed. |
| The order total without VAT | What a shop quoting prices without VAT usually wants: the money it actually books. |
| The order total without VAT or delivery | The same again, less the delivery charge, for owners who treat delivery as a cost passed on rather than as sales. |
Three things worth knowing:
- It only affects Google Ads. Google Analytics is left exactly as it is. Its reports expect the whole total and show you the tax and delivery separately, so taking them off there would break the sales reports rather than fix them.
- Changing it is a fresh start, not a correction. Orders already counted keep the figure they were counted at. Your reports will have a step in them on the day you switch, and any target you have set was worked out from the old figures, so it wants revisiting at the same time.
- Nothing changes when you take an update. A shop that has never touched this setting carries on reporting exactly what it reported yesterday. That is deliberate: an update does not get to rewrite what your account has been told for the past year.
Things worth knowing
Ad blockers. A fair slice of visitors block Google outright - reckon on losing somewhere between a tenth and a third of them. Combined with people declining cookies, the numbers in Google will always read lower than the orders in your admin. Your admin is the truth; Google is the sample.
Give it a day. Google Ads conversions can take a few hours to appear, and Analytics reports settle overnight. A quiet first afternoon is not a fault.
Your web address must match. If the address registered in Google Ads is not the address your site actually runs on, conversions are recorded against nothing at all, silently. Check it if the orders are not showing up.
Your site's security policy already allows Google. Cactus keeps a strict list of which outside companies may run anything on your pages, and this module adds Google's addresses to it when installed. You do not have to do anything - but it does mean the module has to be installed and deployed before Google's own "is the tag there?" check can succeed. If that check fails on a site where everything else looks right, an incomplete deployment is the first thing to rule out.
One block, not two. Put the Google Tag block on the header layout only. It will not double-count if it ends up in the footer as well, but there is no reason to have two.
Not in this version
- Leads, quotes and sign-ups. The plumbing carries them already, but each needs its own conversion action set up in Google Ads first, so nothing is guessed at. A later release.
- Server-side measurement (Enhanced Conversions and the like), which is what recovers the visitors ad blockers hide. Also a later release.
Related
- Configuration reference - the cookie banner settings
- Shop - where the orders come from
- Modules - installing and updating modules