Tracking clicks on videos in Google Analytics
A client has a site where video content is populated by AJAX from a video CDN. Each link is built like so:
<a class="thumb-link" href="/?video='.$video->id.'" onclick="show_video('.$video->id.', \''.$section.'\'); return false;"><img src="'.$thumb.'" width="100" height="65" alt="" align="left" /></a>
But they report that analytics is not tracking the href, since the onclick is telling a Flash player to load the content via javascript instead of go to a page and load the video.
What can I do (without going to a physical page) to track this click as if they clicked throug开发者_如何学JAVAh to a page?
Can I add to the onclick and do something like:
http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._trackPageview
Add to the anchor: onclick="trackVideo();"
Then, with javascript:
function trackVideo() {
path = $(this).attr("href");
var pageTracker = _gat._getTracker("UA-XXXXX-XX");
pageTracker._trackPageview(path);
}
I am not too familiar with Analytics, so if someone could get me in the right direction that would be great.
Your example is correct. That would do exactly what you want :)
精彩评论