1. Home
  2. /
  3. Web Design & Development
  4. /
  5. SEO
  6. /
  7. How to add Google Tag Manager script on your website?

How to add Google Tag Manager script on your website?

Google Tag Manager Script to your webpage

Google Tag Manager can be used to make your conversion tracking easy by simply adding only one script on your website for almost all conversion trackings. And, then utilizing the Google Tag Manager account features to set up different conversion tags without messing up with the website time and again.

To start with, you can create your account on https://tagmanager.google.com/ by using your Gmail account.

Note*: You don’t need separate google analytics script on your website if you have configured Google Tag Manager.

Add a New Account

Add a New Account Tag Manager
Through the Admin section, create a new account.

Fill up details such as your business name, website address, and select “WWW” for setting up a tag manager for the website. And, finally, click on Create to proceed further.

Tag Manager for the Website

Accept the Google Tag Manager Terms of Service Agreement by clicking on “Yes”.

On proceeding further, you will receive the following screen with the script that needs to be added in the head section as high as possible and after the opening of the body tag as close as possible.

Tag Manager Terms of Service Agreement

Copy the two scripts and save it somewhere in separate text files.

Add Google Tag Manager Script to your webpage

Now, open your website header.php or header.html file or any other .php or .html file which you need to track.

Add the first script in the <head> part, it should be close to this tag. And, the second piece of code right after opening the <body> tag.

Add Google Tag Manager Script to your webpage

Now, save the file and make sure its updated and uploaded on the server as well. And, switch back to the Google Tag Manager Account.

Google Tag Manager Script to your webpage

Create a Tag for Google Analytics within your Google Tag Manger account

Click on Add a New tag or Tags from the left as shown in the above screenshot

Create a Tag for Google Analytics within your Google Tag Manger account

Click on New as shown in the above screenshot.

Add a name for this tag e.g. Google Analytics (by replacing Untitled Tag).

Add Tag Configuration

And, then click on Tag Configuration block

Click or select Google Analytics: GA4 Configuration

Add Tag Configuration

Change the name of “Untitled Tag” to “GA4 Tag Configuration” or anything you would like to keep.

Enter the Measurement ID.

The measurement id can be found in your analytics.google.com account.

Make sure you’re logged in to Google analytics account >> Click on Settings >> Data Streams >> Your custom data stream. You will see something like this.

Google analytics account

Copy the Measurement ID and enter it in the tag manager as explained above. And, Save the changes.

Now, leave the other settings as it is and add a trigger for this tag.

Add a Trigger

Once you have added the Tag configuration, you need to create a trigger for it.

The trigger will ensure the tag fires on specific events. In our case, we are trying to track all page views. So, the trigger will be as follows.

Click on the Trigger section and select “All Pages”

Add a Trigger

Save all the changes.

You will see the final screen as follows:

GA4 Tag confoguration

Save the changes.

You have successfully configured a Tag, Trigger, and variable.

Successfully Configured a Tag, Trigger, and Variable

And, now it’s time to publish the changes you have made to this Google Tag Manager account.

Click on Preview to review the changes or make any corrections or final changes or simply click Submit

Add a Version name, Version Description providing an insight on what you have done.

Click on the Publish

Wait for Google to save all these changes and publish… and that’s it. You’re done.

By now, you have successfully created your account on google tag manager, created a tag >> trigger, and linked it with your website. This will now start tracking your website just like the use of Google Analytics script. Additionally, it will offer a more dynamic approach to add as many tags and triggers as possible without making any unnecessary changes on the website end.

One thought on “How to add Google Tag Manager script on your website?

Leave a Reply

Reviews & Ratings Get your stoe online with Shopify in 60 minutes Shop Now