Google Tag Manager events

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

Hello Shaun,

Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

And also, please confirm which one you are tracking, a contact form, complete sale or the order value?

Best Regards.

Hey there, thanks for your reply.

Sorry, I forgot the url!

I will find out if there’s a preference, but for now let’s try and track a complete sale.

Thanks again,
Shaun

Hi @ShaunCoward,

The instruction from that thread is just about adding google tag manager, implementing a tracking code for the event or action is different. Example, if it’s tracking a clicking of a form button, then the tacking should be bound on a button, but it’s tracking a submission then it should be bound on successful submission (through ajax success result or redirection) instead of just on a button.

Since you’re tracking a complete sale and I’m assuming on Woocommerce platform, please check this https://gtm4wp.com/how-to-articles/how-to-setup-enhanced-ecommerce-tracking. For other trackings like forms like Contact Form 7, then check this https://www.3whitehats.com/knowledge/advanced-contactform7-tracking-with-google-tag-manager/. You will have to contact each plugin author for proper implementation.

Thanks!

Ok great, I went down the route of using the Google Tag for WordPress plugin as you suggested and it’s all up and running.

Thanks again.

You’re most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.