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
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.
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.
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.
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.
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
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
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.
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”
Save all the changes.
You will see the final screen as follows:
Save the changes.
You have 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.