是否有机会跟踪点击次数并从iframe获取推荐流量?
我有管视频网站,我的视频已嵌入到许多其他网站上,但无法在其他网站上嵌入视频时找到跟踪iframe内部链接点击的解决方案
这是我网站上的嵌入代码
<iframe src="http://mysite.com/embed.php?id=4589"></iframe>
我试着把embed.php放在像这样的东西
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-111111-1']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('http:' == document.location.protocol ? 'http://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
而且我改变了链接到这个
<a href="http://mysite.com/video/55454.html" onclick="_gaq.push(['_link', this.href]);return false;">Continue</a>
但这不是解决方案
答案 0 :(得分:1)
如果点击位于iframe内,您应该使用:
window.parent._gaq.push(['_trackEvent', eventCategory, eventAtion, eventLabel]);
答案 1 :(得分:0)
您可以在js文件中添加默认的ga代码,并将其包含在所有嵌入的页面和视频页面中,即embed.php,55454.html等
要触发对事件的分析,请使用以下内容
//send to analytics
// var _gaq = _gaq || []; //if already loaded e.g. single page app, keep comment out
// _gaq.push(['_setAccount', 'UA-YOUR-ACCOUNT']); //comment out if single page app
_gaq.push(['_trackPageview','/home/landingPage']);
//sendEventToAnalytics
// var _gaq = _gaq || []; // if single
// _gaq.push(['_setAccount', 'UA-YOUR-ACCOUNT']); // if single
// _gaq.push(['_trackPageview']); //if single
_gaq.push(['_trackEvent', eventCategory, eventAtion, eventLabel]);
查看api, https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide