Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:23:05+00:00 2026-06-17T04:23:05+00:00

I run a standard google analytics tracking code (ga.js asynch version) on a website.

  • 0

I run a standard google analytics tracking code (ga.js asynch version) on a website.
I am wondering if there is a line of js I can add to the tracking code so that I can segregate dev/prod data? e.g. when I pull in the codebase to do dev work, I can set the tag to DEV. When releasing back to production, DEV tag gets replaced with PROD tag.

Is this even possible and if so, how do i implement it?

One method I thought of is just to create a new “property” (which would generate a new ua number, which I could add during dev. that would allow me to track it all separately.)

Wondering if there are any other methods I should consider.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:23:06+00:00Added an answer on June 17, 2026 at 4:23 am

    I’m not worried about collecting data from my development server, but I do want to make sure I’m not polluting my production data — I’ve been using some variation of the following:

    if (!/devServer|localhost/.test(window.location.hostname))
    {
        _gaq.push(['_setAccount', 'UA-11111111-1']);
    }
    

    On the devserver domain (or on localhost), _setAccount doesn’t get executed, so the tracker defaults to the default tracker, UA-99999999-1. This allows you to still see tracking data being sent to the analytics servers (via ga_debug.js, chrome dev tools, firebug, fiddler, etc), but doesn’t register against your production profiles.

    Downsides — it is an extra bit of code that get’s run on the client.

    If you do want analytics from your development servers, you could try something like:

    gaq.push(
        [ '_setAccount', 
          /devServer|localhost/.test(window.location.hostname) ? 'UA-11111111-1', 
        'UA-22222222-1']
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a standard HTML input that I want to run JavaScript code when
I have standard source code package under Linux which requires to run ./configure make
It seems that I have more trouble getting standard Unix things to run on
I wonder if anyone can help? After Google announced that it will take note
I'm considering writing my own tool for tracking visitors/sales as Google Analytics and others
I run this website http://www.gipote.dk where users can create ads to sell dogs, puppies
I've been working on a statistical translation system for haiti (code.google.com/p/ccmts) that uses a
So I've run into a case where I have a class that can store
I'm obviously developing in debug mode. If I'm starting with the standard run command
I run a local directory website (think yelp/yell.com etc) and need to provide analytical

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.