Hey scarey1952,
Are you getting standard GA tracking coming through? Like page views and such?
Hi Ash,
Yes, Sessions, Users, Pageviews, Bounce Rate, etc. are coming through.
In that case, I can only suggest that you fill in the category and label for your adverts. I never tested without them so I can’t confirm whether or not that would be the problem.
Okay, I’ll give that a try.
Here is the GA code which is located toward the bottom of the <body> section, not the top like I mentioned before:
<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-59716263-1’, ‘auto’);
ga(‘send’, ‘pageview’);
</script>
Good news! I filled in the Campaign and Banner Name fields for each of the active adverts and I still didn’t see any stats showing up in GA. Then I moved the GA Javascript code from the bottom of the <body> section to the <header> section and now it appears to be working. It was definitely worthwhile filling in the Campaign and Banner Name fields because this provides us with useful details like which specific ads are being displayed and the position on the page.
So far, I’m only seeing Impression events data, no Click events even though I purposely clicked on a few of the ads. I don’t know if the Click events are not being tracked for some reason even though the Ad King Pro Track Clicks option is checked, or if we just need to give it more time for the stats to show up on GA. Any thought about this?
Thanks for your help.
Hi scarey1952,
That great to hear. I’m surprised the location of the GA mattered however the fact that it did would suggest that the JS was erroring on the impression because GA hadn’t loaded yet. This may also be the reason for the clicks not working.
Are you able to see if theres any notable JS errors in the console?
Generally speaking I would say to wait at least 24 hours for GA to update however if your already seeing impressions then that delay may not be required. To not waste any time, lets wait that 24 hours and see if those clicks display. If you could let me know either way and I’ll investigate further if need be.
Thanks
Hi Ash,
I turned on the Javascript debugger and console in my Firefox browser and clicked on an advert. The following error appeared in adkingpro-functions.js:
TypeError: $ is undefined
I can see this is a jquery error, so I viewed the source to see if any jquery libraries were being included in the <header> section and found the following 2 libraries defined above the GA Javascript that I inserted yesterday:
<script type=’text/javascript’ src=’http://wp.localheadlinenews.com/wp-includes/js/jquery/jquery.js?ver=1.11.0′></script>
<script type=’text/javascript’ src=’http://wp.localheadlinenews.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1′></script>
Do you know why this error is appearing and how I can fix it?
Thanks
Hey scarey1952,
Oh wow…. line 44? Dunno how that one got past me. If you open up /wp-content/plugins/adkingpro/js/adkingpro-functions.js and change this line:
From:
ga = $.parseJSON(ga);
To:
ga = jQuery.parseJSON(ga);
That should fix it up. I will release this change shortly, but to get you up and running, try that.
Ash,
I just made the change you suggested and got the following syntax error:
SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data jquery.js:4
Hey Scarey1952,
So sorry about this – what a mess.
Please replace the entire “track_click” function with the following:
function track_click(post_id, ga_fields) {
if (typeof(post_id) == 'undefined') return false;
if (typeof(ga_fields) == 'undefined') ga_fields = false;
if (ga_fields) {
if (ga_fields.implemented == 'classic')
_gaq.push(['_trackEvent',ga_fields.campaign, ga_fields.click_action, ga_fields.banner]);
else if (ga_fields.implemented == 'universal')
ga('send', 'event', ga_fields.campaign, ga_fields.click_action, ga_fields.banner);
} else
jQuery.post(AkpAjax.ajaxurl, {action: 'akplogclick', ajaxnonce : AkpAjax.ajaxnonce, post_id:post_id});
}
Alternatively, I have updated the plugin with the above code in version 1.9.17 and you can update to that if you’d like.
Please let me know how you go and thanks for sticking with me though this.
Hi Ash,
I just tried out this new code and it looks like it’s working! I clicked on an advert and there were no JS errors showing up. I checked the GA stats and saw a click event showing up under Real Time–>Events. I didn’t see a click event under Behavior–>Events yet, but I can’t expect it to display instantly there. I’m sure it needs a little time to show up under Behavior.
If I upgrade to version 1.9.17, is there any danger of losing adverts data? We have a large number of adverts out there.
Thanks so much for you responsiveness and help. Much appreciated.
Steve
Hey Steve,
Thats great news – glad to hear we got it sorted out.
Provided you dont have the “housekeeping” option ticked, updating the plugin wont have any affect on your data.
Thanks again for your patience.