Dimitris A
Dimitris A

Reputation: 1

Google Blogger/Blogspot onclick event in link will not pass to Google Analytics

I have the following snippet of code in a post in blogger/blogspot but I will not see this event in Google Analytics in Real Time.

<a href="http://example.com" target="_blank" onclick="ga( 'send', 'event', {'Ebook', 'Download', 'ebook.pdf'});"><button>Download</button></a>

FYI the head in the blog includes the following:

<script type="text/javascript">
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
        ga('create', 'XXX', 'auto', 'blogger');
        ga('blogger.send', 'pageview');
      </script>

(id removed on purpose)

Does blogger block such info from flowing to GA?

Is there anything that can be done?

Thank you

Upvotes: 0

Views: 352

Answers (1)

maggieto
maggieto

Reputation: 613

It seems to be using a custom tracker name, more about it here: https://developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers

You can try the following:

onclick="ga( 'blogger.send', 'event', {'Ebook', 'Download', 'ebook.pdf'});"

Upvotes: 1

Related Questions