Will Google Analytics track traffic if cookies are disabled in my browser? - javascript

I want to know whether Google Analytics will track traffic on my website, if my browser has cookies disabled?
I tried to search on Google but couldn't find much information about this question.
I would appreciate if you can also provide me with a source link.
Thanks

No, if you disable cookies, Google Analytics will not track you.
Google Analytics tracks you by creating cookies (or using existing cookies it finds). Then it uses that cookie information in the request it sends to http://google-analytics.com/__utm.gif. That "request" to get the __utm.gif is how the data is transmitted to Google Analytics.
Googling this is a bit difficult, since it mostly just turned up information on the cookies themselves, not what happens when they're disabled.
So, I did an experiment to prove it. I loaded StackOverflow in a fresh FireFox install with cookies disabled.
Below is the list of HTTP requests. Note that it loads ga.js, the Google Analytics script that attempts to track you. But, no request for __utm.gif is made. ga.js merely runs, realizes its unable to create cookies, and as a result has no way to create "state" from pageview to pageview.
Without cookies, Google Analytics would view every single "hit" as its own visit, and each of those visits would be a bounce. This data would be useless. As a result, GA makes the logical choice to just not track those people.

The answer appears to be YES, below is what google has to say.
The "measurement protocol" can even work withOUT cookies or js, it seems to be in beta so you have to request access.
Universal Analytics supports data collection without browser cookies.
The Universal Analytics collection methods (analytics.js and the Measurement Protocol) can be implemented and used to collect visitor usage data without cookies. These methods also work if cookies are cleared or disabled. Website visitors that don’t want their visit data reported by Google Analytics can install the Google Analytics opt-out browser add-on to opt-out.
Source: http://support.google.com/analytics/bin/answer.py?hl=en&answer=2838718

Thanks for the explanation however I thougfht cookies or no cookies Analytics will still record a vist but just can't track it. So when you say "Google Analytics would view every single "hit" as its own visit, and each of those visits would be a bounce." are you implying this is still recorded as say a 0 second or 100% Bounce visit? Or Analytics records no visit at all?

It can, but only if the site owner sets it up that way, which is difficult. The problem is tracking a user across different URLs while maintaining a UUID.
The short answer is yes - but only if the site owner found his way around the pitfalls.
I did it on my website.

Related

Cross-domain conversion tracking - Custom vs GA?

Say I'm starting a site, refer.com, where I post items on an 'affiliation' basis. When users click on my links, they're directed to the site shop.com. If the user I redirect to shop.com makes a purchase, I need that conversion tracked.
I see two possibilities:
Creating a custom tracking library (probably JavaScript) where I
request URLs from refer.com to transfer information from shop.com. I guess PHP would work too, but reduces compatibility with clients.
I use Google Analytics cross-domain tracking to do this. I don't
want the refer.com GA account to interfere with the shop.com GA account, but as I understand it you can use several accounts on the
same page, giving them different identifiers.
I feel like I'm stuck with a narrow set of possibilities. Do I do both? Neither? I need it to be as easy to implement as possible for the client, while also providing relatively bullet proof tracking. What's the standard today? Affiliation services are everywhere, and this type of cross-domain tracking has to be a very used technique. Is there another preferred method of achieving this that I'm not aware of?
This question might seem highly theoretical. While that may be true, answers with code are highly appreciated too.
I have a way for this to work but it requires both your domains to have the Universal Analytics code installed. This will not work with the older GA code
https://support.google.com/analytics/answer/1032400?hl=en
You can install multiple instances of the Google Analytics tracking code on your web pages to send data to multiple properties in your account.
You can, for example, install multiple instances of the Universal Analytics tracking code (analytics.js) on your web pages but only one instance of the Classic Analytics code (ga.js).
So (provided they have your GA code installed) when you refer to shop.com what you should do is this
Parse your GA cookie. You can get to it by $_COOKIE['_ga']. The cookie holds a string that has four parts, broken up by periods. (i.e. GA1.3.367110421.1357220305). You want those last 2 numbers (in this example 367110421.1357220305)
Pass the parsed cookie data in your referral to shop.com
shop.com should store the parsed cookie in its session
Last but not least, when shop.com has your referral data it should load your GA code and set your sessions up like this
ga('create', 'UA-YOUR-GA-CODE', {'cookieDomain': 'shop.com', 'clientId': 'USERS-PARSED-SESSION'});
What this does is it passes your GA session to their domain. At this point, GA will keep their session going so you can track what happens on shop.com. Any conversion data they pass to their GA code should be passed to your GA as well.
Is it bulletproof? No. You have to trust shop.com to properly retain and show your referrred GA session ID. But I have to use this methodology to keep my sessions between my primary sites and the centralized checkout we use and it preserves my Adwords conversions, etc.
I feel like if you're looking for ease of use for the client, Google Analytics is a pretty solid option. It is a widely used tool, with lots of documentation and active forums for feedback. Also, from my research on the topicit seems that they've got this type of behaviour in mind already.
An alternate that comes to mind is that, when redirected from site A to site B, they should be forced to authenticate on site B. You could then setup an authentication form that is unique to this referral from site A, and will be filtered into your database separately from regular authentications on site B.

How to disable Google Analytics pageviews tracking but keep event tracking?

I have a WordPress plugin which bloggers can opt-in for tracking. The data is used to improve the UX in yhe plugin's management dashboard settings pages.
Since we are only interested to track some button click events and don't really need the "pageviews" tracking, is there any way to tell Google to disable the pageviews tracking? I want to respect the publishers privacy as much as I can, and if there's no reason to track pageviews I would prefer to block it.
Disable pageview tracking
The default behavior of this snippet is to send a pageview hit to Google Analytics. This is the desired behavior in most cases; pageviews are automatically tracked once you add the snippet to each page on your site. However, if you don’t want the snippet to send a pageview hit to Google Analytics, set the send_page_view parameter to false:
gtag('config', 'GA_TRACKING_ID', { 'send_page_view': false });
From :https://developers.google.com/analytics/devguides/collection/gtagjs/#disable_page_view_tracking
You could do this with the Measurement Protocol directly. The Measurement protocol is just some HTTP posts or gets that send the data directly to your Google Analytics account. The JavaScript code that you get from Google basically does just that.
It is a little tricky there are some required fields you have to send or the data wont record correctly. But if all you want to be able to do is track some button clicks sending the events along shouldn't be to hard.
This is untested example:
http://www.google-analytics.com/collect?v=1&tid=UA-XXX-Y&cid=35009a79-1a05-49d7-b876-2b884d0f825b&t=event&ec=file&ea=upload&userclicked&ev=1
CID just needs to be a session id some way of knowing one user session from another.
NOTE: This will not record all of the normal data. you are going to loose things like language, location, pagepath. This is probably only going to store the event nothing else. I would consider putting it in its own web property to keep the data separate from any true Google Analytics recorded data.

How does Google Analytics restrict domains?

My understanding of cross-domain restrictions is that you can't verify which domain is loading your content using javascript or iframes. How, then, does Google know what incoming data is coming from users accessing the real domain? If someone uses my GA embed code on a different site, how does google know the difference?
Google Analytics, in its default behavior, does not differentiate or validate the source of the data.
If someone were to maliciously put your GA account ID on their site, you'd get their data transmitted back to your account as if you'd put it on your site yourself.
However, by default, ga.js will append a hostname, from location.hostname, to the tracking data and have it available as a dimension. So, any traffic sent from foreign hostnames could be tracked, managed and segmented out.
If this becomes an issue, you could configure a Google Analytics filter to either exclude traffic from specific malicious domains, or include traffic to your specific domains.
This is very rarely an issue that comes up for people.
The GA JavaScript (and any other JS you embed on your page) has access to the location object which contains the full url, domain, etc.
Cross-domain tracking is required anytime you want to track
GA in a single session across multiple domains that you control.
If you do not use or have it configured wrong,
you will have meaningless data and will also have a shortage of assignments for their point of conversion.
Google Analytics uses first-party cookies that are attached to the visitor's browser.
Those cookies contain data about when the visitor last visited the site, what page it was,
and a variety of other data. When the user clicks between pages or comes back at a later date,
the ga.js javascript looks for the existence of that first party cookie. If it doesn't find a cookie,
then it views that visitor as a brand new visitor (that has NEVER been to your site). First party cookies are great,
but for security reasons, they do not transfer between domains. The first party cookie is linked directly to the domain that set it
and will not be accessible by any other domain.
If you want to get data from a domain specific, you can create a filter hostname, the type of insertion.
That is, only receiving data exclusive to this domain
Using the old version of Google Analytics, clicking on the visitors > Network Settings > Hostname you can see the information of
domains that are sending data to you.

Google Analytics - how GA tracks users after removal of Cookies?

If the Google Analytics cookies are removed from the web browser, how GA tracks that if it was the same computer from where a site having GA.js code was accessed?
for instance, www.stackoverflow.com has GA.js code to track it's visitors. A user opened it in his/her browser and GA starts tracking the traffic, but the next hour all of the browser cookies are removed.
NOW, how GA will track the same user accessed this site before?
*This cookie is typically written to the browser upon the first visit to your site from that web browser. If the cookie has been deleted by the browser operator, and the browser subsequently visits your site, a new __utma cookie is written with a different unique ID. This cookie is used to determine unique visitors to your site and it is updated with each page view. Additionally, this cookie is provided with a unique ID that Google Analytics uses to ensure both the validity and accessibility of the cookie as an extra security measure.* - Google: http://code.google.com/apis/analytics/docs/concepts/gaConceptsCookies.html
So it doesn't track them as the same user.
If you're very interested, I recommend their "Conversion University" videos: http://www.google.com/support/conversionuniversity/bin/request.py?hl=en&contact_type=indexSplash&rd=1
If you really wanted, you could cross reference an ip number with a browser fingerprint, and have a pretty good lock on a browser / location combination as a result. However, there are two reasons most people won't bother:
It's a big pain in the bum
It doesn't give users the option of not being tracked, which they might not like, and it might not even be legal, depending on privacy laws which constantly change with technology.

Is it possible to use the Google Analytics API to provide stats for customer's page views?

Let's say I run a site where customers are willing to pay for a page that shows some sort of cool info about them. The whole site is tracked using Google Analytics.
To provide stat tracking for the customers, would it be possible to mine the data from Google Analytics, using the AJAX API?
Are there any show-stoppers I should look out for before attempting this?
Trying to prevent from writing my own stat tracking solution.
Update, a bit more clarification: I'm looking to be able to build a stats page that shows a few stats for a specific url (page views, traffic sources, etc...), not necessarily in real-time. I would cache the page to prevent hitting API rate limits.
There are 2 major impediments: One technological, and one legal-ish. Together, they make using Google Analytics Data Export API an unfit solution.
Technological: Google Analytics Data is not available in Real-Time. Delays in data processing run from 3-4 hours to 24-48 hours. Page-views are processed fasted; things like custom variables often take a day or so). In theory, you could tag each user with a custom variable, and then query against that custom variable for information.
Legal-ish The Google Analytics Terms of Service prohibits you from collecting personally identifiable information. So, you can't use a custom variable that stores their username on your site without violating the Terms of Service. Here's the relevant section.
PRIVACY . You will not (and will not allow any third party to) use the
Service to track or collect personally
identifiable information of Internet
users, nor will You (or will You allow
any third party to) associate any data
gathered from Your website(s) (or such
third parties' website(s)) with any
personally identifying information
from any source as part of Your use
(or such third parties' use) of the
Service. You will have and abide by an
appropriate privacy policy and will
comply with all applicable laws
relating to the collection of
information from visitors to Your
websites. You must post a privacy
policy and that policy must provide
notice of your use of a cookie that
collects anonymous traffic data.
As far as alternatives, it depends on what information you want. You can access their IP address on the server side and use that with a third party tool or a command line call to find out their rough location (much the same way that Google does). You can similarly access their referer on the server side. Much of the information that gets sent to Google actually gets stored in the Analytics cookies (_utm prefixed cookies). There's a wide body of literature on reading these cookies (See: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=how+to+parse+google+analytics+cookies)

Categories

Resources