What is difference between Page Views and Event type in Google Tag Manager and where "some page views" are stored in Google Analytics? - google-tag-manager

I am kinda new in this topic and wondering what is the difference between Page Views and Event data type in Google Tag Manager. I would like to create an e-commerce funnel. I have configured tags for every steps in GTM and they work properly in preview mode. But I can't find them in Google Analytics. I've been creating tags with pageview -> some page views tags. Where this type of tags are stored in Google Analytics? Should I change it to event data type? And in which case could we need some pageviews tags otherwise?

GTM and GA are two different systems, that unfortunately use the same words for rather different things.
GTM is a deployment system for Javascript tags. In GTM Parlance, an "event" is something that makes GTM update its internal variables and allows for triggering tags. GTM events manifest themselves as a key with the name "event" in the datalayer (GTM overwrites the "push" method of the datalayer array to detect the "event" key when it is contained in an object that is pushed to the datalayer). A pageview in GTM is just one type of event that happens when the GTM code is first executed. By itself it does not send data anywhere and nothing is stored. Data is sent only by the tags that are configured to be triggered by an event.
GA is a system that records tracking data. Tracking data is sent as "hits", where a hit is a http request with a payload that is formatted according to a certain protocol (the measurement protocol, which can be used in any language that supports http requests, and is also used by the analytics.js library). Hits come in different types (pageview, event, timing, and possibly others). The difference is not so much technical (its all http requests), is that the different hit types are by convention tied to different "dimensions", i.e. descriptive properties of the hit. A "page view" hit has a document location and document title. An "event" in GA has additionally the dimensions "event category", "event action" and "event label". That distinction made sense when GA was created, because back then a "page view" was more or less well defined by browser behaviour, but today with ajax and SPAs and all that it becomes more an more meaningless, which is why GA4, the new version of Google Analytics, now only has one hit type - the event, to which you can add dimensions by way of parameters.
So a page view in GTM maybe configured to send a page view in Google Analytics, but does not have to be; the two things have the same name, but exists independently. If a GTM event is not recorded, then it probably has not GA tag connected to it via a trigger. GTM events by themselves do not store data anywhere.
As for the funnel, in Universal Analytics you would create this by implementing enhanced e-commerce. Enhanced E-Commerce can be implemented both via pageviews or via events (that mostly depends on how your page is structured - if you have a checkout with multiple pages you might want to use page views, if everything happens on one page you would rather use events). The important thing is that the appropriate dimensions and metrics are attached to the hit. In GTM the easiest way to this is to have your developers set up the datalayer structure according to the linked documentation, and then you simply check the "enhanced e-commerce" feature in you GA tag and point it to the e-commerce variable in your datalayer (instructions are in the documentation, if you expand the "See the Tag Configuration for this Example" sections by clicking on them).

Related

Is there a common list of areas to check while comparing GTM and analytics.js data in Google Analytics?

I have a website where we're working on migrating from analytics.js to GTM, so we've created a new temporary property for verifying that GTM is working as per expectations. The existing analytics.js code sends data to an older property.
I see a lot of cases where many users simply don't appear in the GTM tracking data, and we've also done multiple pageview audits to confirm if all pages are tagged properly. There's always a gap of 10-15% in the user comparison, and 20-25% in the pageview comparison.
Has anyone worked on any similar situation where GTM tracking shows lesser data than normal analytics.js tracking?

Google Analytics configured with GTM showing two pageviews. But when I check GTM assistant it only shows one

I have configured Google Analytics using GTM in my single-page application build in next.js. In order to check the pageviews I push a custom event to the data layer called "pageview" each time a user change to a new page.
In GTM I have created a trigger that looks for the "pageview" custom event and fires up the google-analytics tag.
Everything seems to be working properly but when I enter the debugview of google analytics and I change from one page to another 2 paweviews are recorded instead of one.
I have check GTM assistant and the tag is not firing twice, so I do not know where the problem might be.
This is messing my stats as I have twice more pageviews than in reality.
Here in the photos i upload you can see the tag. In the history and message no tags are getting fired
While this is what happens in google analytics (both page_views contain the exact same parameters (same page_refererr, page_location...):
Here is the implementation insine next.js. Basically I call the function GTMPageView() each time a route is change. GTMPageView() is the function that pushes "pageview" into the datalayer
I really appreciate any kind of help as I have been hours trying to solve the problem and I cant get to the end of it.

Google Tag Manager - (enhanced) e-commerce - how to load Javascript after <body> tag

I'm still learning Google Tag Manager and Enhanced E-commerce tracking, but I have a few questions, some of which may be pretty basic:
We're using a site on a third party system - I already have Google Tag Manager in my template within the HEAD tag, working with Universal (Google) Analytics. However, we want to just get the e-commerce transaction (purchase) data into Analytics - so basic e-commerce tracking would be fine, but I'd rather use Enhanced E-commerce tracking since it is newer - even though my immediate requirement is just to track purchases.
So, I need to send push transaction data into the dataLayer, but I can't do this due to restrictions on the system. I can only add special Javascript code to the end of the BODY tag for my "checkout complete" page.
Reading this online, the dataLayer must be defined in the HEAD before the GTM code is in place. As I cannot do that, I need to load the data using Javascript at the end of BODY.
Is this possible, if so how? I think I can do this using a Custom Javascript Variable as mentioned here: https://developers.google.com/tag-manager/enhanced-ecommerce#macro
Is a "macro" the same as a "variable" as explained in the above link? It says "macro", but Google Tag Manager allows me to define a custom "variable" which is "Custom Javascript". Just checking that these are one in the same.
Where would this code actually "run", if I put it in Google Tag Manager? The third party system defines some variables for me during script execution and I don't know where/when (during page load of the checkout thank-you page) it does it, so to be safe, I'd rather have this script run at the end of the page before the BODY tag closes - if I were doing this manually using plain Javascript within the HTML. In Tag Manager, how would I tell the Javascript to run "at the end of the page"?
Thanks in advance!
1 - Use dataLayer.push() in your Custom Javascript at the end of the BODY. Include an event in this with the transaction data.
For Example:
dataLayer.push( 'event' : 'custom.transaction', 'ecommerce': {} );
You can see the ecommerce object structure here:
https://developers.google.com/tag-manager/enhanced-ecommerce#purchases
dataLayer.push() is used after Google Tag Manager script has been included on the page, so you won't need to define it in the head of the page. Just translate your available ecommerce data into the structure required.
You then need to set up a Custom Event trigger in Google Tag Manager that uses/matches your event value/name.
Then create a Universal Analytics Event Tag that uses this Trigger. Set what ever you would like for the Category, Action and Label. Under More Settings > E-commerce, check Enable Enhanced Ecommerce and then check Use dataLayer.
This event is simply used to pass the Ecomemrce Data into Google Analytics.
2 - Macro is the same as Variable. You are correct Custom JavaScript Variable is what you are after.
3 - The code lives in Google Tag Manager Variable scope and is executed when the variable is used and/or with Google Tag Manager state changes. You can't make this code run at the end of the page. Also this code would need to access/scrape values from the page. To ensure the data is available you would only use this Variable on a Tag that is set to trigger on Window Loaded / DOM Ready, depending on when the on page data is ready.
I would suggest using dataLayer.push() and only use the Custom Javascript Variable approach if dataLayer.push() is not possible.

GTM / GA: Cross-Domain Tracking (VIEWS & GOALS)

Situation: I have used Google Tag Manager to set up Google Analytics (GA - Universal) on a multisite network. There is one GTM container, and each website has its own GA property. I used a GTM variable to reference all of the GA properties. I am able to track cross-domain sessions. In testing, I am able to follow a user's session across multiple domains under the same session / client ID.
Problem: I'm stuck with what to do next. I'd like to create some Goals and Views that track a user's journey through my sites and measure the usual stats (bounce, drop-off points conversions, etc.). However, I'm not sure where to begin. I see plenty of information on the Internet for how to set up cross-domain GA tags in GTM. However, I don't see anything out there for how to create Views and Goals for cross-domain setups. A few questions that come to mind are:
Do I create Goals in the destination site's GA account (e.g. mycheckout.com), or the site where the session begins (e.g. myproductinfo.com)?
When creating Goals, do I only use the permalink slug, or the entire link? I thought I could only add the permalink.
How does this information roll up into one report?
I found this link, but I'm not sure if it's the 'best practice'. I would greatly appreciate it if someone who has previously implemented this could provide an outline of best practices, or a link to a good tutorial on the subject.
Thanks for your help!
Chris
You need to understand GA definition of Views and Properties. Views are like database table views: you can either show the whole table or a sample of it.
To have all data collected without sampling a "Raw Data" view (no filters) should always be used. Each view has its own conversion goal definitions. So in the "Raw Data" view you can create a goal for any page tracked. If you filter a view for one domain (e.g. "confirmation.com View with appropriate filters"), only goals for this domain should be created (otherwise they will never count a conversion).
When creating goals you can define filters for the "ga:pagePath" parameter. So it depends on your GA tracking setup, what part of the URL it tracks. Go into chrome web developer toolbar and hit the "network" tab. Open your page in this tab. Then search for requests ending with "collect", these are the data trackpoints send to GA. There you can debug what URL information is sent to GA (search for the "dl" parameter within the query string parameters list).

Conversions in GA stopped being attributed to UTMs when we switched to Google Tag Manager

Previously, we had implemented Traditional e-commerce analytics (_gaq) using _trackTrans, _addItem, etc. We had several years of data in GA that correlated conversions with our Ad campaigns, based on UTM source, campaign, medium.
When switching over to Google Tag Manager, we did the following things:
• Removed the _gaq code related to e-commerce (transactions & addItem)
• Kept the rest of the GA code related to page tracking, events, and custom variables
• Implemented the Google Tag Manager javascript + a GTM data layer that included our new E-commerce information (Google Tag Manager data layer)
• Configured a "Tag" in GTM for "Order Completed" for Google Analytics, set to Universal Analytics (Configured with our UA- property identifier, etc.). Tag type= Universal Analytics; Tracking ID= our GA environment, Track Type = "Page View" , Enable enhanced e-commerce feature = true, Use data layer = True; Fire on "Order completed"
Upon switching over, we indeed see E-commerce numbers come through, but there's something off about the recording of these conversions correctly back to the campaigns. It appears that while some are attributed back, not all conversions are counted correctly as being from the ad campaign they originated from.
What went wrong here? After thorough reading of the GTM documentation, we were led to believe that it would "just work" but it appears that GTM and GA don't know how to communicate with each other regarding UTM information, and as a result GA tracks conversions but fails to attribute them to right session (that is, ITS session information that contains the correct UTM for that user).
We found a very scant amount of information about this on the internet-- but some people suggest setting all the UTMs are "Variables" in GTM, and then passing them as fields in the Tag firing back to GA. Is that necessary? It seems like these two technologies should work together with less friction.
Please advise.

Resources