Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Tag Manager: Eventtracking not working

I try to track the clicks on all mailto-links on my site using the Tag Manager, but its not working at all. Looking at the network transfer using firebug I can see that nothing is submitted to Google (and of course also nothing appears in my Analytics interface).

I have bind the push to the click using jQuery (correctly loaded on my page):

$(function() {
    $("a[href^='mailto:']").bind("click", function() {
        dataLayer.push({
            'event': 'GAevent',
            'eventCategory': 'Mail Link',
            'eventAction': 'clicked',
            'eventLabel': 'My Event Label'
        });
    });
});

Then in the Google Tag Manager interface I set up a Tag as Google Analytics Tag with proper Web-Property ID (like UA-XXXXXX-X). Type is set to 'event' with the following parameters:

Category: {{eventCategory}}
Action: {{eventAction}}
Label: {{eventLabel}}

The field for value is empty, non-interaction is not set.

To trigger the event I set up a rule {{eventLabel}} equals My Event Label.

Of course I have also created the following Macros:

Name: eventLabel
Type: dataLayer variable
Name of variable: eventLabel

Name: eventCategory
Type: dataLayer variable
Name of variable: eventCategory

Name: eventAction
Type: dataLayer variable
Name of variable: eventAction

Name: event
Type: user defined event

Do you see any errors in this? Why is nothing sent to Google?

I know that i.e. the user defined variable is actually not needed but I don't see a problem in having it set up anyway.
The jQuery selector is also fine, when I bind console.log the the same event I can see it my message in the console.

like image 626
user2807681 Avatar asked Dec 10 '25 05:12

user2807681


1 Answers

Two things:

You should have an event = GAEvent. You can create this by creating a new macro > Custom Event and setting the macro name to GAEvent.

enter image description here

On your rule, you will need to add your event = GAEvent to your rule.

enter image description here

like image 103
Blexy Avatar answered Dec 12 '25 19:12

Blexy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!