user8160918
user8160918

Reputation:

Google Analytics event not firing

My Google Analytics event isn't firing on my webpage. Below is my code. It opens the url in a new tab just fine, and there are no errors in the console. But when I go to Google Analytics -> Real-Time -> Events my goal has no activity. It's using Universal Analytics because when I view page source I see analytics.js.

<a href="https://myurl.com" onclick="ga('send', 'MyEvent', 'Click');" target="_blank">under construction </a></p>

If it helps, my Goal setup is:

Category - MyEvent
Action - Click

Use the Event value as the Goal Value for the conversion - Yes

Upvotes: 0

Views: 5588

Answers (2)

ravina vala
ravina vala

Reputation: 129

New version of analytics has a different syntax: Replace this line

ga('send', 'MyEvent', 'Click');

With

gtag('event', 'click', {'event_category' : 'MyEvent', 'event_action' : 'Click', 'event_label' : 'Label is optional'});"

Upvotes: 3

ztadic91
ztadic91

Reputation: 2804

you are missing the hit type property.

ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

Full documentation is here

Upvotes: 1

Related Questions