I need a modified Javascript which inflated the pageviews, unique visitors and visitor count!
For educational purposes because I want to see if there are certain patterns when artificaly altering the G. Analytics report
I coded this but it does not work:
<script type="text/javascript">
var i=0;
for (i=0;i<=10;i++) {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19629541-9']);
_gaq.push(['_trackPageview']);
_gaq.push([_setDomainName, '.domain.com']);
_gaq.push([_setDomainName, 'domain.com']);
(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);
})();
}
</script>
and this Code only alters the pageviews:
<script>
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script>
// Google Analytics
var pageTracker;
try {
pageTracker = _gat._getTracker("UA-15064357-1"); // pour dystroy.org
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
for (var i=10; i-->0;) pageTracker._trackPageview();
} catch(err) {console.log(err);}
</script>
I am asking becasue I recenlty viewed an analytics report which did not quite mach up with all the underlaying data
thanks
There’s no garanteee that breaking the GA code in a specific way will produce the same results as another GA broken code.
If you’re trying to understand a specific trend that might have been caused by a broken GA code then you should maybe post the trend and your findings so far to Pro Webmasters and see if they can pinpoint the specific issue.
Just a spoiler to whoever might be looking at it.
ATTENTION don’t do this on your site. This is a GA broken code.
UPDATE
Some explanation of what I’m doing here.
I’m creating 2 trackers and I haven’t touched the
_setDomainNameproperty. It means that both trackers are using the same cookies. But one of the trackers use_setAllowHashtrue and the other false._setAllowHashis deprecated these days so you don’t really need it. But what it does is that when false it disables the domain hash, that’s the number you see in cookie _utma before the first dot. When the domain hash is disabled this number is just 1.When the first tracker runs it disables the domain hash and creates the cookie, then it fires a pageview. When the second one runs it sees the hash doesn’t match what it was expecting, so it creates a new cookie, overwriting the old cookie.
They keep running one after the other, removing and recreating the __utma cookie. Turns out that this cookie also holds the visitorId, so that pageview is seen by Google Analytics as a new visitor with a brand new visit.
This is, unfortunately, fairly common to see around, and thankfully
_setAllowHashis deprecated, so there’s no good reason to use it at all. So it shouldn’t happen a often as before, but there are still some settings that can cause problems like this.The rule of thumb is if you use multiple trackers always use the same settings with all of them.