Site logo

Archived topic

Tracking Google Ads Events on a Category and Thank You Page

42 replies · Started by Georgi on December 1, 2022

Viewing posts 31–43 of 43

Thanks, Ying!

David - I put the code you told me in the hook, but the thank you page started crashing. When a customer completes an order, he is redirected to the thank you page and it's completely blank.

So I guess it doesn't work.

Hi Georgi,

I thought I replied that the code should be added to functions.php or the code snippet plugin.

It would NOT work in a hook.

Hi Ying,

I realized that afterwards and moved it to the functions.php but it still doesn't track anything.

Whilst viewing the thank you page, Right Click > Inspect the page to open the browser developers tools.
In the developers tools there is the Elements tab, select that and use CTRL-F to open the search, and search for part of your script eg. gtag.

If the code work then you should be able to see your script in the head of your site.

I opened the developer tools and made a purchase. On the thank you page I searched in Elements like you told me and found the gtag. However developer tools also report an error that gtag is not defined: https://prnt.sc/KIR9YVXfouJZ

Any clue what's happening?

Ok, so the hook is working, the gtag is not defined will mean that the gtag.js has not been loaded.
I assume that means you haven't hooked in your GTAG scripts for that page ?

you haven’t hooked in your GTAG scripts for that page?

What do you mean? What I did only is to put the code in functions.php
Besides that, I've a hook created with GP for the Google Ads tracking code to work only on 1 product category which is currently showing ads for.

That function you added is just a GTAG, and that requires the Google Tag Manager to be added to the site and loaded before the GTAG script is fired.

Have you added google tag manager to your site ?

Ah, no. The idea was to put code directly in pages via GP hooks/functions.php to avoid using GTM plugin.

I'm not well-versed in GTM, so I have to ask:

Technically, if I add the GTM code from the artictle you sent me only on the thank you page, will it measure conversions?

I have a GTM account but I haven't set up anything in it. I guess just copying my GTM ID and putting in the code from the article will still not measure conversions value?

I hope so too.

This archived topic is closed to new replies.