Google Tag Manager - Data Layers - google-analytics

I was looking into implementing Google Tag Manager: Data Layers so better track the behaviour of my users and I was wondering if the following was possible:
Pushing data to multiple Google Tag Managers
Either through custom javascript or
Just placing two Google Tag Managers and letting the DataLayer push to both of them?
Basically, we have two parties who want to data, however, one party will have access to more information while the other will only need some of the datalayer push
For example:
Party 1: DataLayer push - "Name", "product", "no of product sold"
Party 2: DataLayer push - includes all of the above plus "cost","margin" etc
Thanks in advance,
Lee.

Yes, even in multi-GTM situation, you use one DL.
Typically, you never give third party data consumers access to your GTM because that gives them the power to execute arbitrary JS on all your pages and that is a serious security concern. If it's necessary, consider not giving them publish access to veto their tracking implementation.
One GTM instance can handle numerous stakeholders and send different pieces of data to different endpoints.

Related

Google Analytics duplicate purchase reports

We are trying to setup GA4 analytics without removing (at the moment) the previously setup UA, a scenario which is described on the official documentation :
[UA→GA4] Send events to both your UA and GA4 properties
Our problem is that specifically for the purchase event which is a default tag, we see duplicated reports in GA4 Ecommerce Purchases.
I suppose that this might be expected since we push 2 purchase events to the dataLayer as described in the following 2 docs for each version respectively:
Universal Analytics (Tag Manager) - Measuring Purchases
GA4 Ecommerce - purchase
It seems like the GA4 report is picking up both purchase events, despite the fact that we use a different model for each event push. So for example in the end we get :
One (1) purchase event with revenue $10.00 on UA reports,
Two (2) purchase events with revenue $20.00 on GA4` reports (which is wrong)
Is there any way we can use both UA and GA4 and be able to remove the duplicate purchase events on our reports somehow? Tried removing one of the 2 dataLayer push events but then one of the 2 reports (GA4/UA) is missing information.
Well, just make a CJS variable that would parse the event's content and indicate whether this payload has UA or GA4 structure. Then utilize the var as a check right in the GA4 EEC trigger. Actually, I would update the GA3 UA EEC trigger too, just in case it suddenly is able to consume the GA4 object.
But your general approach is sub optimal. How analytics agencies do this kind of job is by reusing the old UA DL pushes and sending the EEC payloads manually rather than through automated DL EEC tracking.
As benefits:
Your dataLayer still looks well and uncluttered by duplicate e-commerce information.
You don't bother front-end devs with extra work and it's easier to maintain
Much easier to introduce symmetrical changes especially when you want to introduce, say, a new product- or EEC hit-level custom dimension or metric.
Data parity does not depend on the front-end devs, only on the GTM config.
Less tags/triggers cluttering in GTM.
It's way-way-way faster to do it when you already have a template GTM container for such mapping. Not sure if the agencies share the containers yet though.
Cons:
A bit more code in GTM.
If GA3 breaks, GA4 will inherit the breakage automatically. Data parity is a double-edged sword.
I can't share my containers, unfortunately, but they look similar to this: https://github.com/gtm-templates-knowit-experience/ga-eec-to-ga4-ecom-converter/blob/main/template.tpl feel free to give it a shot and let us know if it does the trick.

How to send Google's Data Layer data to other analytics paltform

I'm trying to set up an events tracking pipeline for my website to track different kinds of events like button clicks, page views, capturing form fields etc. Now, I'd like to store this data somewhere, one way is to send this data to Google Analytics but it doesn't store string type of data like form data.
Is there some way to send DataLayer data to other third-party platforms and store it?
If not, what's the best way to access/export this user-level data
dataLayer is an object loaded on a page. This means that you can access it and pick it up with Javascript and pass it on wherever you like.
However, the fact that there is a dataLayer, makes it probable that there is Google Tag Manager installed on those pages. If that is true, you can use GTM to pass on those values from dataLayer (even if they are the contents of the form, like name, email, etc. which you must not push to Google Analytics) to whichever other platforms.

How to implement Google Tag Manager across dozens of sites within the same network

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.

how to turn Google analytics on or off depending on user log in?

I currently have website (vb.net) that uses google analytics and it has been working fine. What i want to do is turn off GA when the employees of my company log in and turn in on when the clients use it. Each login has a unique id so the first thing that i thought of was to just check the id and add/remove the GA code depending on who logs in. I'm not sure if doing this will affect the stats in any way. Are there other ways to achieve this? Thanks
Depending on your use case, it could be better to utilize this data by placing it within a custom variable, saying if the member is an employee or a regular user. Within the reporting you could then segment the traffic based on value. In most cases this will be the better option as you won't have an inflated drop off rate at the login screen.
If you're still needing to abort the calls, you have a few options:
Add the JavaScript window['ga-disable-UA-#######-##'] = true; on the page. This will need to be done before you call the normal Google Analytics code.
Add logic to fire or not include the entire Google Analytics code block if the user is within a certain group or has a certain ID. This will obviously depend on what language you're developing in.

can google analytics tell me http referrer for each specific goal conversion?

I have a website that allows people to create an account (that is the conversion I wish to track).
I wish to know where a specific person is coming from. I have google analytics installed and have set up the registration page as a goal, but the reporting tells me traffic sources as an aggregated pie chart. It doesn't report down to the user account level to say that 'person with email xyz' came from 'facebook' for example.
What custom variables or mark up would I need to add to GA to report at that detailed level, if that is at all possible?
Otherwise, I will just have to record the first http_referer in a cookie and stick it in a database during the registration process.
Any advice?
Firstly I must ask you, how actionable do you think it is to look at data at that granular of a level? Finding out what % of people who registered came from facebook or some other place is actionable, because it helps you do things like determine where to focus marketing efforts. But individual users? How is this actionable to you? (hint: it's not)
However, if you are still determined to know this, you should first note that it is against Google's ToS to record personally identifiable data both directly (recording the actual value in GA) or indirectly (e.g. - recording a unique id that you can use to tie to personal info stored within your own system). If this is something you don't want to risk, I suggest moving to another analytics tool that does not have this sort of thing in their ToS (e.g. Adobe SiteCatalyst, which costs money, or perhaps you may instead prefer to choose an "in-house" approach, like Piwik)
If you are still determined to follow through with this and hope not to get caught or whatever, Google Analytics doesn't record data like what info a visitor filled out in a form (like their email address) unless you populate that data in a custom field/dimension/metric/event to be sent along with the request. Usually you would populate this on the form "thank you" page (which is usually the same page you use as your goal url or goal event if you're popping and using an event for your goal). So you would populate the email address in one of those custom variables and then have it as a dimension to break down the http referrer by.

Resources