Question

I am trying to monitor the download of a single/specific file using Google Analytics code on a Wordpress site. I am unable to verify if I am using Google Analytics Classic or Google Universal Analytics (Google has responded and what they said does not make any sense, I have asked them again and have waited over a week for a clear reply). I have used their code in my download "a" tag and it will not record in the Behavior-> Events page in GA. What am I doing wrong? I have over two days for it to log and I have tried both the GA classic and Google Analytics Universal Code (below uses Universal Code)

What am I doing wrong?

<h4><span class="colored">///</span> Study Questions</h4><br/>
<div class="well center">
<a class="btn btn-inverse btn-small pull-left" href="http://www.mannachurch.org/online-    video-notes/letsmove_questions_pt1.pdf" ga('send', 'event', 'Questions PDF', 'click');     target="_blank"><i class="icon-file"></i><strong> Part 1</strong> • (pdf)</a>

It is for this site page, under the Study Notes Tab:http://www.mannachurch.org/portfolio-type/lets-move/

Was it helpful?

Solution 2

There are two things that I can see in the in the site you linked that might be causing you problems The first is stated in the answer by Pablo Romeo:

you need to add onclick="code here" in order to send event when the user Clicks the link.

<a class="btn btn-inverse btn-small pull-left" href="http://www.mannachurch.org/online-video-notes/letsmove_questions_pt1.pdf" onclick="ga('send', 'event', 'Questions PDF', 'click');" target="_blank">

The second problem is the location of your Google Analytics tracking code on that page. Its at the bottom of the <body> tag you should move it so its with in the <head></head> tags

<script>
    (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','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-43995008-1', 'mannachurch.org');
    ga('send', 'pageview');
</script>

OTHER TIPS

You can't just add javascript code into the href attribute concatenated with a url.

You should probably do something like the following:

<a class="btn btn-inverse btn-small pull-left" href="http://www.mannachurch.org/online-video-notes/letsmove_questions_pt1.pdf" onclick="ga('send', 'event', 'Questions PDF', 'click');" target="_blank"><i class="icon-file"></i><strong> Part 1</strong> • (pdf)</a>

Or a more elegant way would be to use jquery instead of the onclick event.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top