Google Analytics testing/sandbox environment?

23,920

Solution 1

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

Solution 2

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

Solution 3

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.

Solution 4

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

Solution 5

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.

Share:
23,920
Laimoncijus
Author by

Laimoncijus

Updated on August 06, 2022

Comments

  • Laimoncijus
    Laimoncijus almost 2 years

    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?

  • Scott Coates
    Scott Coates about 11 years
    The significance of _setDomainName is to specify the domain of the tracking cookie. developers.google.com/analytics/devguides/collection/gajs/…. This allows sub-domains to share the cookie.