Setting Custom Campaign _setCampNameKey not working in Google Analytics ga.js

纵然是瞬间 提交于 2019-12-04 20:50:28
nwellnhof

Since _trackPageview triggers the tracking process, you must put the _set* commands before the _trackPageview command to be effective.

Another solution is to setup custom campaigns via URL parameters.

Edit: Also see the answer to this question. The _setCamp*Key functions don't set the value directly but the name of another URL parameter which contains the value. For example, you have to put the campaign name in a separate URL parameter like:

http://mysite.com/?camp_name=My+Campaign

Then you can tell GA that the my_camp_name contains the campaign name:

_gaq.push(['_setCampMediumKey','camp_name']);

In your case, it might work to pass a custom URL with these parameters to _trackPageview:

_gaq.push(['_setAccount', 'my profile id']);
_gaq.push(['_setDomainName', 'mysite.com']);
_gaq.push(['_setCampNameKey','camp_name']);
_gaq.push(['_setCampMediumKey','camp_medium']);
_gaq.push(['_trackPageview', 'http://mysite.com/?camp_name=<?php echo $this->campaignName?>&camp_medium=<?php echo $this->campaignMedium?>']);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!