Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics testing/sandbox environment?

Is there any Google Analytics testing/sandbox environment for testing your JS custom code before putting it to live system?

I don't want to use my real tracking ID to see if everything is correct on my dev. environment, neither I want to put my code untested live...

Is there any techniques or maybe some fake Analytics tracking lib I could use for testing?

like image 851
Laimoncijus Avatar asked Mar 22 '10 12:03

Laimoncijus


People also ask

Can you test Google Analytics on a localhost address?

js code, the Google Analytics, Advanced Configuration - Web Tracking Documentation shows that we can test Universal Analytics on localhost with this new code: ga('create', 'UA-XXXX-Y', { 'cookieDomain': 'none' }); Check out the linked documentation for more details on advanced configuration of Universal Analytics.

How do I create a demo account in Google Analytics?

You can always get access to the demo account again. Sign in to Google Analytics. Click Admin. In the ACCOUNT menu, select Demo Account.


5 Answers

The Google Analytics Debugger Chrome Extension is very helpful in testing Google Analytics code. The extension outputs the data sent to Google Analytics to the JavaScript Console Window. The days of you...waiting around...hoping/praying to see your test Pageviews in Google Analytics are over.

Below is an example of some of the output the extension prints to the JavaScript Console Window:

Track Pageview
Tracking beacon sent!

Account ID               : UA-2345678-90
Page Title               : About
Host Name                : www.yourdomain.org
Page                     : /about
Referring URL            : -
Language                 : en-us
Encoding                 : UTF-8
Flash Version            : 11.1 r102
Java Enabled             : true
Screen Resolution        : 1680x1050
Color Depth              : 16-bit
Ga.js Version            : 5.2.4d
Cachebuster              : 476867651
like image 169
James Lawruk Avatar answered Oct 02 '22 16:10

James Lawruk


I believe it is possible, but you have to tell it to not use the domain when setting the cookie...

var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._setDomainName("none");
pageTracker._trackPageview();

And you probably have to use a legitimate tracker ID.

Also, be sure to see Analytics Customizations: Using a Local Server

like image 31
Josh Stodola Avatar answered Oct 01 '22 16:10

Josh Stodola


Why don't you just create a new tracking code / profile in GA? That way you can see the results on your dev server and then switch to the real tracking number when you move to live.

like image 21
David Radcliffe Avatar answered Sep 30 '22 16:09

David Radcliffe


I think a lot has changed since the question was asked, but I believe I should add this here just for the new visitors since it is not in the answers.

Google Analytics now has a Sandbox Account that you can create. Check out the source for the direct announcement by them.

Short instructions from the link:

If you already have a Google Analytics account, you'll need to create a new one as your "sandbox" by following these instructions:

  1. Click Admin at the top of any Analytics page.
  2. In the Account column, click the menu, then click Create new account.
  3. Follow the instructions.

Source: https://groups.google.com/forum/#!category-topic/digital-analytics-fundamentals/6EYCkNdE2No

like image 24
zeta Avatar answered Oct 02 '22 16:10

zeta


I think it should be done with "views" in 2019.

  1. Create views for development and production https://support.google.com/analytics/answer/1009714?hl=en
  2. Create a custom dimension "environment" = "test" / "prod". Send it from website/app.
  3. Create filters by custom dimension "environment" on view level https://www.bounteous.com/insights/2015/10/16/filtering-session-user-custom-dimensions-google-analytics/

Maybe for some projects filters can be done by URL instead of custom dimensions.

like image 27
Vincente Avatar answered Sep 30 '22 16:09

Vincente