for my job I am doing an research projekt on the validity of Google Analytics (mostly in regards to the verified reports on flippa) --> see if it is possible to completly fake G. Analytics (a simple Yes will not cut it)!
I modified the G. Analytics code as following:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19629541-5']);
_gaq.push(['_setAllowHash', false]);
_gaq.push(['b._setAccount', 'UA-19629541-5']);
_gaq.push(['b._setAllowHash', true]);
for (var i=0;i<=10;i++) {
_gaq.push(['_trackPageview']);
_gaq.push(['b._trackPageview']);
}
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
It will now spawn multiple visits and visitors when you run it. You can see that the second number on __utma changes for every pageview, that number is the visitorId, when it changes it means you get a new visitor
The problem is that the stats I get now look like this:
Please not the extreme decrease in avg. visit duration!
before they were similar to this:
Now my question: How would I need to modify the G. Analytics Code (if at all posible) to make it look similar to this:
so basically increase the amount of Visits, Unique Visitors, Pageviews 10 fold yet leave the other stats the same.
Examples on http://jsfiddle.net are greatly welcomed
PS: sorry for my bad English (not my mother tongue)
Google Analytics defines timeOnPage and timeOnSite on server side, the code is based on the time elapsed between the pageviews you sent. Since all this is done server side there's no way to fake this unless you space out your pageviews by the amount of time you wish to fake.
You also need to send more than 1 pageview per tracker to get the correct amount of pages/visit. Currently everytime you switch between the 2 trackers you reset cookies and the previous visitorId is lost forever.
So you want to do something like this:
I would say that you probably want to introduce some more randomness still keeping the same average. For example in order to get the right BounceRate you'd need to have 57% of the visits firing a single pageview. And in order to get the right New Visitors metric you need to come back with one of those old ids but within a new visit to spawn a returning visitor. You can trigger a new visit by deleting the __utmb or __utmc cookies, or just waiting longer than 30min between a new pageview.
As you can see the closer you want to fake the numbers with the true the harder it might get.
This now becomes a little impractical to live in a single page script. Since it may take a couple seconds to complete and you probably want to emulate this thousands of times. So maybe it's better to create this use a headless browser like phantom.js that you can trigger multiple simultaneous instances of to get the results you want.
I wonder what kind of analysis you're planning to extract from these. Depending on the type of analysis what you already have is enough or maybe the effort to have a better emulation is not worth the insight.
You're not going to be able to do this within one web page. The problem is that whenever you reset the hash it spawns a new session which will cause the first "visitor" to leave, lowering avg. visit of duration and increasing the bounce rate.
I believe you could accomplish everything except for the Unique Visitors * 10 requirement by doing the following:
ga.htm
.src
of ga.htm
, we'll call this include-ga.htm
.include-ga.htm
file at the bottom of all your pages.This should artificially make GA think the user is viewing 10 pages at once which should multiply all your stats in unison, except for Unique Visitors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With