Google Analytics for Multiple Environments (Dev/QA/Prod)

    Let's cut to the chase, I was looking for a way to use a single account with a single property and have multiple views. I thought this was very possible would be easy to manage data that way but I wasn't sure how. After playing around a little with the interface I figured it out. None of the resources directly helped but were really good insight. What I also figured out was that you can use a single line of code to do this, so no need to change the javascript in each environment. This is great because I don't need to alter the javascript snippet to point to the difference environments.

Analytics example
Google Analytics
Filters
    You will need these order to separate the data between different views, use the filter on your views not the property. Under Admin, select your view and then Filters. For all the filters (Dev,QA, Prod) I did a Predefined, Included only, traffic to the hostname and that contains.  I've seen in some environments where dev and qa are on a subdomain in which case you might want to use "that begins with". In my situation these two make no difference in the results, but I would test either way.

Why do this
    This is a question I asked myself and the reasons are very simple but might not always be meaningful within a small team for your dev environments. That's assuming that you have this kinda of setup but even if you have a small team you can use analytics on your dev systems to find 404's, load speeds or just to test analytics itself. Since its the same javascript snippet it makes it really easy to use and forget about it once its in your solution.

Resources
Google Analytics with multiple environments - somewhat helpful
javascript - Google Analytics testing/sandbox environment? - Stack Overflow
Syntax Comparisons - Google Analytics — Google Developers - I'm not keeping track of my local environment just cause I don't think I would get much use.

Popular posts from this blog

Nginx Best Practices Extended

Installing Windows on Acer chromebook 15 cb3-532

Entity Framework: ToListAynsc & WhereAsync