Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If a site visitor clears cookies, uses various browsers or computers then Google Analytics will have a hard time detecting them as being by the same user.

However since 95% of the site content is only available when logged in, so I should be able to identify multiple visits as the same user so long as they log in.

How can I help Google to identify that the visits are by the same user? (without breaking the Terms and Conditions)

share|improve this question

Saving the GA cookies on each page view and then restoring them if they were not present on the users next login would have the desired effect. Storing the cookie data in a database against a user id would not be against the GA TOS http://www.google.com/analytics/terms/us.html

You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.

Google provide server-side code to read the cookies that could be used as a starting point: https://developers.google.com/analytics/devguides/collection/other/mobileWebsites and here is a (slightly old) blog post explaining the cookie data: http://blog.vkistudios.com/index.cfm/2010/8/31/GA-Basics-The-Structure-of-Cookie-Values

share|improve this answer

Actually, if your system allows to identify the user of your system personally (e-mail, surname etc., FB/Google login), then you'll definitely breach the agreement.

But in order to detect the same user you have to be able to "connect the dots" - which requires personal identification as I consider. Your interest in aggregated data should be called fair use. And Google doesn't treat you as a fair player at any point of time. Thus, you'll need to gain user's consent for fair tracking and do it yourself.

share|improve this answer
That's exactly what I want to avoid. Apart from breaching the agreement, the exact browsing habits of individual users is of no interest. I'm only interested in aggregated data but over a wider context than google supports by default (sessions). – Craig Nov 3 '12 at 0:16
@AB In the post you linked to, you seem to suggest it would be possible and offered some steps to achieve it. Have I misunderstood? – Craig Nov 3 '12 at 0:34
No, there was a need to identify users, but not against the will - once they reset the session, they'll have new identity. Your problem lies in question: detecting them as being by the same user. – ABerezovskiy Nov 3 '12 at 0:50
And I just now realized that you problem is deadlock in its root. So I edited my answer. – ABerezovskiy Nov 3 '12 at 0:51
If I saved the GA cookies on each page view and then restored them if they were not present on the users next login this would have the desired effect without identifying the user individually, which I think is a variation of your earlier edited post and wouldn't break the agreement. – Craig Nov 3 '12 at 1:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.