Enable Event Tracking With Google Tag Manager Simple Script

by Josh Koop | Last Updated: November 3, 2020
As an Amazon Associate we earn from qualifying purchases made on our website. If you make a purchase through links from this website, we may get a small share of the sale from Amazon and other similar affiliate programs. You can read our complete disclaimer information for more details.

Like many people it is very nice to know which external links are the most popular on your site. This method through Google Tag Manager (GTM) is entirely free instead of paying for “advanced” accounts on plugins like Monster Insights.

What you Need:

  • Google Analytics Account Code – (UA-XXXXXXXXX-X)
  • Google Tag Manager Account – Here

Steps To Configure GTM

  1. Build an Account In GTM
  2. Build A Container in GTM
  3. Import JSON Tracking Script – Download – Right Click Save As
  4. Add Google Analytics Tracking ID Variable
  5. Publish To Live

Build An Account In Google Tag Manager (GTM)

Sign Into GTM with your Google Account – Click on Create Account

Add The Account and Container Details (Similar to screenshot)

Click Create

Agree With The Terms Of Service

You will get 2 Codes Once Completed, Install HFCM plugin (Search HFCM there is a single match)

In HFCM -> Add Snippet -> Name Google GTM Header Code -> Make sure set to run in Header -> Paste in the <head> code

In HFCM -> Add Snippet -> Name Google GTM Footer Code -> Make sure set to run in Footer -> Paste in the <body> code

Click OK to close out the code

Import JSON Container

Now you will need that JSON file you downloaded above and saved to your desktop or other location

Click on Admin -> Container -> Import

  • Select File -> JSON from above
  • Workspace -> Existing
  • Import Option -> Overwrite

Next You Will See A Confirmation (Click Confirm)

Adding Google Analytics Tag

  • Click Variables From Left Menu
  • Click [ NEW ]

In the top right where it has [ untitled ] paste this text


This isnt your UA code, just paste exactly the bolded text

Click on Variable Type [ Select Constant ] (Towards bottom on right)

In [ Value ] paste your UA code from Google Analytics

Click Save

Click Submit

Name The File [ My External Tracking Code ]

Click [ Publish ]

You are done it should show this screen, then you can close out of GTM

Hopefully this helps you start to track external links to Amazon and left you see what links are the most utilized on your site.

I love technology, I have plenty of technical side experience but never really thought of blogging as a way to earn an income. With everything that has gone on in the last couple years and the instability of the job markets I started to learn how to blog and build affiliate niche sites to add more income channels to give me the chance to break free from the financial chains that bind me and find real freedom!