javascript - Content Script tracking with Google Analytics -


i working on google chrome extension modifies pages content script. in order understand when , changes applied looking google analytics since use other web properties already.

we include ga.js library via manifest file, , trigger _trackpageview synchronous page call when apply change page.

var pagetracker = _gat._gettracker("ua-our-ua"); pagetracker._setdomainname("none"); pagetracker._setallowlinker(true); pagetracker._trackpageview(window.location.href); 

trouble here each pageview in different domain counts new visit , visitor. there way circumvent that? example use chrome extension sqlite database or key value store in browser store unique user id , visit id domain independent. possible?

thanks

you should not execute code inside other people sites. google analytics configuration sensitive , if site has custom implementation might breaking visitor.

you should include google analytics in own background page. , communicate content_script background page everytime need track event.

by including ga script on background script nice because don't interfere other code on website , execute same domain , use same cookies not causing duplicated visits/visitors.

here more info on how install ga on background page.

http://code.google.com/chrome/extensions/tut_analytics.html

and here's docs passing information content scripts background page:

http://code.google.com/chrome/extensions/messaging.html


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -