Dum Potato
Dum Potato

Reputation: 965

Google analytics Report manipulation

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

Upvotes: 1

Views: 461

Answers (1)

Denys S&#233;guret
Denys S&#233;guret

Reputation: 382274

An analytics report can only be trusted as long as you trust the site developers.

A developer can modify it to register the events and page views he wants to have. That's totally normal.

It's a tool for the developers and the site owners, not an independent proof of the popularity of a site.

EDIT : I just tried to add a loop on one of my sites (for which I really don't care about analytics) : http://dystroy.org/re7210/

<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>

And it works :

enter image description here

Only multiples of 10.

Upvotes: 1

Related Questions