Reputation:
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
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