开发者

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开发者_StackOverflow社区 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?


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


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


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜