Strona nie jest aktualnie dostępna w Twoim języku. Możesz wybrać inny język u dołu strony lub przetłumaczyć na wybrany język zawartość dowolnej strony, używając funkcji tłumaczenia dostępnej w Google Chrome.

Tracking Interactions Via the Data Layer

Manual event tracking using GTM

Events in GTM

There are 2 approaches to choose from when implementing interaction tracking in GTM:

Both approaches achieve the same goal of sending an event to Google Analytics. The difference is in where the complexity of the implementation lies: in the page code or in GTM.

Data Layer Events require that code be placed on the page in order to populate the data layer with information specific to the event being tracked. From there, these have a simpler GTM component: a single event tag configured to fire based on the contents of the data layer.

Auto-Events require no modification of the page code. Instead, each event that is tracked requires its own tag and trigger to be configured in GTM.

Auto-Events are more flexible and have a less technical implementation component compared to Data Layer Events. However, they are also more susceptible to problems resulting from website changes (specifically, changes to the DOM). As such, it is generally recommended to use Auto-Event Tracking for measuring interactions with elements identifiable based on properties that are not likely to change (e.g. link URLs, element IDs/classes, etc.). Conversely, use Data Layer Events for measuring other interactions (including those events that cannot be listened to with Google Tag Manager listeners, such as clicks within Flash videos or mouseover events).

Data Layer Events

GTM tags for GA Event can be triggered based on the contents of the data layer object (as opposed to GTM-based triggers, known as Auto-Events). For DOM-level 0 (and other event listeners) use the manual datalayer push method to trigger events through the datalayer.

As a simple example, consider the case when an event should be fired whenever a user hovers over an image. The following data layer push can be issued.

<img source="#" on-hover="datalayer.push({
  'event': 'analyticsEvent',
  'category': 'engagement',
  'action': 'button click',
  'label': 'call to action'
});">

You can then create GTM datalayer variables that map to the categoryaction and label items in the data layer and reference these in the event tag in GTM.

In order to trigger this tag, you can create a new trigger with following configuration:

  • Trigger type: Custom Event
  • Event name: analyticsEvent

It is also advisable to add the following trigger conditions:

  • category does not equal undefined
  • action does not equal undefined

Czy to było pomocne?

Jak możemy ją poprawić?
Search
Clear search
Close search
Main menu
2532719538147405345
true
Wyszukaj w Centrum pomocy
true
true
true
true
true
69256
false
false