Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google analytics - multiple trackers on one page (cookie conflict)

I'm writing a web application that's supposed to be embedded in other people's websites (kind of a widget). I'm using Google Analytics to track all the people that visit all instances of my script on the embedding websites. The problem is that I don't know how to use it so that it doesn't interfere with those websites' own Google Analytics accounts. I'm storing the tracker variable in a namespace, so I thought that should do it, but I haven't realized that GA stores its settings in cookies (__utma, __utmz etc.), and those cookies are used by both trackers, if there are two of them on the same page... So for example if I use _setVar to store some kind of user-defined variable in Google Analytics, and the embedding site does the same, we overwrite each other's values...

Of course it would be easiest if Google provided a way to change the name of the cookies to a custom one, but I can't find any way to do it. I thought about using cookie domain or path to force a separate cookie, but this doesn't work, because if I set domain or path to something other than the real domain/path, then the cookie is not readable for the page after reload...

Does anyone know a way to have two trackers on one page and make them use separate cookies so that they don't overwrite each other's settings?

Or, if that's completely impossible - is there any other analytics service with similar functionality as GA in which this is possible? (it would have to have advanced features like event and campaign tracking...)

like image 596
Kuba Suder Avatar asked Aug 06 '09 13:08

Kuba Suder


People also ask

Can you have multiple Google Analytics on one page?

Creating separate Google Analytics tags. You have to create separate GTM tags for each property. You cannot use a single tag to send data to multiple properties. If you want to send page views to two different properties, you will have to create two pageview tags.

Does Google Analytics use first or third party cookies?

Is Google Analytics a first party cookie? Google Analytics uses first-party cookies in a piece of Javascript that is added to every page in your website. This allows you to track behaviours on your site, however it relies on third-party cookies from third-party sites to scrape referral data.

Does Google Analytics work with cookies?

The Google Analytics JavaScript libraries use HTTP cookies to "remember" what a user has done on previous pages / interactions with the website. Note: Read the Google Analytics privacy document for more details about the data collected by Google Analytics.

Do I need the Google Analytics tracking code on every page?

You do need to put Google Analytics on every page that you are interested in tracking. Depending on what website builder you are using, it is done automatically for you.


1 Answers

Now made easy with the new asynchronous tracking code. :)

https://developers.google.com/analytics/devguides/collection/gajs/#MultipleCommands

like image 107
Paul Thompson Avatar answered Oct 01 '22 09:10

Paul Thompson