I was wondering if it's possible to set up multiple server side experiments using Google Optimize and Google Tag Manager. We followed https://stackoverflow.com/a/52157837/12936081 and it seems to be working just fine with the values sent from the data layer, but given the Analytics variable names (expId and expVar) it feels like we can only do that for one experiment at any given time.
Instead of sending a separate expId and expVar with the Google Analytics - Universal Analytics Pageview, set exp instead to contain both, and separate multiple experiments by !.
Combine that with info found in the referenced SO question and in the official docs, and we have . to separate the experiment ID and the experiment variants, and - to separate any variants in a multivariate test.
For example, if you're submitting experiment ID A (much longer in real life) with variant index 1 (the first non-control variant), and experiment ID B with variant 0 (the control) in the first section, and variant 2 (the second non-control variant) for the second section, you'd set exp to A.1!B.0-2.
Setting up the data layer
If you're creating a test server side, there's no need to resort to any JavaScript in GTM. Simply set up the dataLayer with the exp variable set, then create a variable that references that from the dataLayer in GTM. I found that even though GTM and the Google Analytics Pageview hit run asynchronously, I had to set by data early enough for the GA to pick it up. You could add a separate script tag for this anywhere, or add it to the GTM snippet itself if that's easy to modify. In my case, I just injected this to the end of the <head> via a Cloudflare Worker using HTMLRewriter, since my test is implemented at the edge.
<script>var dataLayer=dataLayer||[];dataLayer.push({"exp":"A.1!B.0-2"})</script>
How I determined this
I found this format by temporarily adding the client-side Google Optimize JavaScript, and launching two concurrent experiments, and then looking at the network request being sent. I've tested this briefly on a dev instance and data seems to come in.
Related
I've recently implemented GA via GTM for a MediaWiki site I'm working on. As part of that configuration, I've setup custom events and variables to capture two custom dimensions (one session scope, and one hit scope respectively).
While the data layer and collect requests (e.g., google-analytics.com/collect?...&cd20=xxxx&cd44=xxxx...) show variables being set and sent, only one of the dimensions is surfaced within the GA reporting UI. More specifically, the session scoped dimension appears when slicing session-based reports, but the hit scoped dimension doesn't appear when slicing page-based reports.
Given the setup, I'd expect it would be all or none on the custom dimensions (vs. only one being captured). Has anyone run into this/any general ideas on what may be amiss?
Make sure all expected custom dimensions are properly defined in your property settings. Undefined custom dimensions will be ignored completely.
You always send your data on hit. The session/user/product level dimension is about the post-processing. Therefore, for a session-level dimension, it is enough for it to be set once per session for it to appear for any hit of the session. Hit-level custom dimensions will only be available for the hits that had that dimension explicitly set for them.
Only 20 CDs are available for free GA. GA360 is required for more. Make sure you're sending data to a GA360 property if you want to use the 44th CD.
I have created a tag within GTM which as part of it's label returns various variables; page path, and various ID's
GT Tag Configuration
As expected, when I view the events in Google Analytics, the label is one item.
Event Action in GA
Ideally I would like them to be separate, so that reports in Analytics can be pivoted on these variables.
Is this possible?
Not as such, but you can create hit-level scoped Custom Dimensions and send them along with your event.
Custom dimensions are basically custom data fields that you can fill with arbitrary data (as long as each value is 150 byte or less). You can use them as secondary dimensions in standard reports, or in custom reports in GA (or in Google Data Studio).
Custom Dimensions will only work after you have configured them. If you need to work with existing data, you could use Google Data Studio, which directly connects to GA, and create calculated fields e.g. by splitting the value by the whitespace character and return the first (second, etc) bit. Data Studio is free, and is for the most part a much more capable reporting interface than GA itself, so it's worth a look.
No, it is not possible. You have to export data and process them for example in Excel.
I have a fully functional and working code (written in C#) which purpose is to track some hits to the specified GA property. This code has been tested and still works successfully. It adds some predefined dimensions (like App Version) to each hit and a several custom metrics to a certain hit types (like event with a certain Event Action).
So far so good everything works flawlessly when taking into account the first property to which these hits are being sent. Also everything is fine when I set up a brand new GA property and track my hits to it - that is, I'm able to see events in Realtime reports, and events show up in custom reports after a while so that I can see my custom metrics.
The issue is that when I try to send absolutely the same hits to the existing property which had been created and configured ages ago - there is no both dimensions (even predefined) and custom metrics in my custom reports. I see these events in realtime and behavior reports, and I'm even able to create a custom report against events count - but that's it. I'm able to use for example Day of the month as a primary dimension, but when I try to use App Version as a dimension or my custom metrics as report metrics - it says "There is no data for this view.".
I've already tried everything I could, have read almost every post about custom definitions in Google and viewed almost each related SO question and answer - still with no luck.
We use measurement protocol
There is a correct User Agent being sent with each hit
17 days has passed since my first attempt to track these hits with existing property
There is no filters and segments at all
There is only one view
For me it looks like a property misconfiguration, but I've inspected each configuration page (I have all possible rights granted) and have not found anything related.
Will appreciate any help with this issue.
UPD: The hit itself (with the sensitive data replaced):
t=event&ec=session&ea=connection_end&el=b225d53a-6bb2-8021-f7b5-ae7004ae0a00&cm1=174960&cm2=1751494&cm3=479033&tid=UA-XXXXXXX-X&cid=4119e77f-be87-4530-04d3-33882f8eea77&v=1&av=XX.XX.99.555&an=my-awesome-app&aid=app.awesome.my
UPD: Here is what I'm trying to achieve (screenshot was made at the test property, where everything works like a charm):
All the while, I've been using the old classic ga.js (e.g. _gaq.push()) to generate monthly traffic report for my clients. Now, I decided to migrate over to the latest gtag.js in order to replace my custom variables with the new custom dimensions (or probably custom metrics as well). But one problem here:
How do I handle the Month Transition for the accuracy of report data?
When I think of parallel run of old and new tracking codes (at least 1 week before the coming month), I found this on Google Analytics Help:
You can, for example, install multiple instances of the Universal
Analytics tag (analytics.js) on your web pages but only one instance
of the Classic Analytics code (ga.js). Multiple instances of ga.js
might result in inaccurate data collection, processing, or reporting.
You can, however, install one or more instances of analytics.js on web
pages that also have a single instance of ga.js.
Therefore, I would like confirm this with some experts here: Is it SAFE to go ahead with one instance of ga.js and one instance of gtag.js on the same page? Note that if I don't implement old and new GA codes at the same time, let's say 1 week before the coming month, my custom variables will lose 1 week data; meanwhile, if I use the new report, my custom dimensions will lose 3 weeks data. Also, I just can't simply implement the new code on May 1, 2019 00:00 AM -- What if my new implementation doesn't work? I need several days to monitor it as well.
So this is important to me. I wonder if anyone of you here has experienced this and can assure me that this is safe to go ahead. Thank you so much!
IMPORTANT UPDATE, May 3, 2019: After using the below method for parallel-run for 1 week, the old tracking code doesn't seem to continue collecting traffic data even though I never change its configurations whatsoever. Apply it at your own risk.
Ok guys, after my full day experiment, it's confirmed that the classical ga.js (_gaq.push()) and gtag.js can be concurrently run on the same page and same site for the sake of resolving the migration issue as mentioned in my question above. The trick here is: Create a new property with new tracking ID for your new tracking code (gtag.js) with similar view settings and custom reports. Below are the steps:
For the new gtag.js:
Create a new GA property for the same website with new tracking code/ID.
Verify and complete your View Settings for the new property if necessary.
Define your Custom Dimensions accordingly.
Create your custom reports if necessary.
Get your new tracking code under your new Property -> Tracking Info -> Tracking Code.
Paste your new tracking code just right before your old tracking code (preferably in a different <script> tag).
Add your custom dimension code accordingly.
For the old ga.js:
Do nothing and keep it as it is.
After the cut-off date is over, just remove or comment out the old <script> tag of your old GA tracking code.
Open both your old and new GA reports with their respective property view and monitor the traffic result. If still no data on the new report, comment out the <script> tag of your new tracking code and troubleshoot again (or else it may affect even your old tracking code as well), make sure your custom dimension code has no errors, otherwise it should work with different tracking code managing different property ID (no conflict). If you need the same solution, hope this helps!
We run a network of approx. 80 different sites (unique URLs) within our institutional enterprise network. These sites are separate and distinct, yet are all live within the same organization.
I have been rolling out GTM to each of the sites on a one-by-one GTM Container ID basis -- meaning each site is getting its own GTM Web Container.
I have seen other instances where similar "networks" utilize one GTM Container ID for all sties within their network.
Given my infancy level and experience with GTM, my question is "what is the proper way to implement GTM across multiple separate and distinct sites within the same common enterprise? Create a separate GTM Cid for each site or create 1 common GTM Cid for all sites?
What are the pros and cons to each of these approaches. Are there technical and/or performance issues with creating dozens, if not hundreds of tags and triggers in the implementation approach of a single GTM Cid?
Thank you for helping me understand the most effective way to implement GTM.
There are two ways I can think of to solve it effectively.
Use the same GTM container ID in all your pages. This way you only have to manage one container and all your changes will be live on all pages. However all pages should be exactly the same, when it comes to tracking. If there are differences, you will have to manage gigantic lookup table variables in GTM. For instance if you need to track GA pageviews in separate accounts you will need to lookup domain value and pass the correct UA-... ID value to track the data in the correct Google Analytics property.
You can use separate GTM container IDs and use one container as a reference. The reference container will need to be exported as JSON file. Now this setting can be imported in all other GTM containers. However you need to rename parts of the setup, so you cant just export and import the setup 1:1. Since also here, static variable values like UA-... IDs will be different in your setups.