I have a image that links to another site in a HTML widget in the sidebar on my site and I would like to track the clicks but for some reason it is not showing up in the "Events"
tab on my analytics.
The code I am using is as follows...
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-***my UA code***']);
_gaq.push(['_trackEvent']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www.***the link I want to track***/) + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<a href="http://www.***the link I want to track***/" onclick="_gaq.push(['_trackEvent','Outgoing Links','NightMarket','advert']);"><img src="***The image i want to track***"width=318/a></a>
I managed to get this working a few months ago but stupidly misplaced the code I used.
Any help will be greatly appreciated!
Cheers!
如果由onclick触发,则通用分析事件跟踪代码应类似于以下内容:
onclick="ga('send', 'event', 'Outgoing links', 'Nightmarket', 'advert');"
Google Analytics pageviews tracking were not working:
(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', 'Tracking ID', 'Domain'); // Replace with your property ID.
ga('send', 'pageview','URL');
Please find the issues involved on the above...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.