Adrian
Adrian

Reputation: 13

Google Analytics - Issue with sending events

I have problem with sending Google Analytics events. I'm trying to use this code:

ga('send', 'event', 'Videos', 'play', 'Fall Campaign', {
  nonInteraction: true
});

to check if someone have watched video. In the header I have script with Google Analytics code but it isn't working.

I use this code:

          window.dataLayer = window.dataLayer || [];
          function gtag(){dataLayer.push(arguments)};
          gtag('js', new Date());

          gtag('config', 'XXXXXXXX');

In 'network' I can't see sended values. What should I do?

Upvotes: 0

Views: 143

Answers (1)

Дмитро Булах
Дмитро Булах

Reputation: 3847

With global site tag you'll have to switch to gtag() command instead of ga() to send data to Analytics. in your case there should be something like

gtag('event', 'play', {
  'event_category': 'Videos',
  'event_label': 'Fall Campaign',
  'non_interaction': true
});

here are the docs on migrating analytics/ga to gtag: https://developers.google.com/analytics/devguides/collection/gtagjs/migration#track_events

Upvotes: 1

Related Questions