Tracking Google Tag Manager
Simply keeps track of the user's actions on the page, for example:
- Header
- Click Logo
- Click Menu Name
- Click Social Media
- Click Search
- Sidebar
- Click Sidebar post
- Article
- Click Share
- Click Next Post
- Click Prev Post
- Click Related Post
- Click Name of Tag
Settings Google Tag Manager
With Google Tag Manager, there are a million different ways to make your tagging setup leaner and more flexible.
I'll use an easy way to reduce redundancy here. It's the generic event tag ? you guessed it!
— What are you waiting? ? hands in action.
First we'll create triggers
- Click Triggers
- New
- Name of the Trigger
- Select Custom Event
- Name of the Event
— If you do not understand. look at the image
Second we'll create Tag
- Click tags
- New
- Name of the Tag
- Select Google Analytics
- Track Type
Event
{{Event Category}}
{{Event Action}}
{{Event Label}}
{{Event Value}}
- Non-Interaction Hit
true
- Here you have to add your Google Analytics code. I have my Google Analytics code in a Global variable. I select my global variable
- Triggering — Select the trigger we created first
— If you do not understand. look at the image
Third Insert code
👉 You can improve the code. I'll leave that to your imagination.
➡️ Copy the below script to Settings -> Code Injection -> Blog Footer
<script>
/* Tracking With Google Tag Manager */
var godoTracking = document.querySelectorAll(".godo-tracking");
godoTracking.forEach(function (item) {
item.addEventListener("click", function () {
var godoCategory = this.getAttribute("data-event-category");
var godoAction = this.getAttribute("data-event-action");
var godoLabel = this.getAttribute("data-event-label");
var godoValue = this.getAttribute("data-event-non-interaction");
dataLayer.push({
event: "godoGhostEvent",
eventCategory: godoCategory,
eventAction: godoAction,
eventLabel: godoLabel,
eventValue: godoValue,
});
});
});
</script>