Hi there,
I followed the instructions here: https://theme.co/apex/forum/t/urgent-please-gtm-stopped-working/51958 and inserted the code into my child theme’s functions.php file.
I’ve now had an email from the company that is running the company’s Ad Words campaign. Apparently it’s not working because I haven’t set up an event. From the email:
Thank you for installing Google Tag Manager onto the website.
I have tried to do some test conversions and these were unsuccessful as it doesn’t appear to have an event on the page.
Please can you follow the below instructions and let me know when this has been added.
This is crucial as, as soon as this has been completed we will be in a position to go live.
In regards to the shopping feed, as soon as a link could be provided I can build the shopping campaign. In the meantime, however, we intend to go live with just search.
FOR AJAX WEBSITES
To Track a Contact-us Form
If the contact-us form is using either AJAX or submitting to the same URL there are two methods that can be used.
1st Method - Thank-you Page:
The first method is to create a thank you page with a unique URL so this can be tracked. After you have created the
created thethank-you page could you please send the URL of the page to us.
2nd Method - Add an event:
The second method is to add an event for google to track when the thank-you message is shown.
First insert the code below between the head tags in the template file. ()Then go to the success/thankyou message and insert the code at the end of the message:
As the success message is displayed, this will send an event into the JavaScript array called dataLayer which is
used by google tag manager to inform them that an event has occurred.
To track a complete sale
If the complete sale has it’s own thank you page please send us the URL of this.
If the complete sale page is using either AJAX or submitting to the same url there are two methods that can be used.
1st Method - Thank-you Page:
The first method is to create a thank you page with a unique URL so this can be tracked. Aftecreated the
thank-you page could you please send the URL of the page to us.
2nd Method - Add an event:
The second method is to add an event for google to track when the thank-you message is shown.
First insert the code below between the head tags in the template file. ()Then go to the success/thankyou message and insert the code at the end of the message:
As the success message is displayed, this will send an event into the JavaScript array called dataLayer which is
used by google tag manager to inform them that an event has occurred.
The event is not needed if using the code for the order value tracking (below) due to having it already present.
Installing Order Value Tracking using Google Tag Manager
On the sale confirmation / thank you page that is being tracked insert the following code:
Javascript Example
Replace the 0’s in the script with the variables that contain the Order ID and the Order Value.
PHP Example
A PHP example with the Order ID and Order Value stored in variables named $order_id and$order_value:
Please inform me of what method you use.
Could you please advise me on the best course of action?
Thanks,
Shaun