Google Analytics: eCommerce tracking seperated by layout - google-analytics

Already have GA (Universal Analytics) and eCommerce tracking setup on my website.
Is it possible to set a parameter in the tracking data, and separate reports by this datapoint?
For my website I have multiple views/layouts: desktop and mobile
Also i have various user entry points: desktop browser, mobile browser, in-store ordering station (iPad showing desktop layout), iOS app that shows mobile layout ("iframe" type solution).
I already have this separated in my business logic, calling it "channel" - which can be "default", "insTore" or "iosapp".
Can I somehow set this parameter in GA, so I'm able to se sales per "channel"?
I've read something about dimensions and metrics in the docs, but unsure if that is what I'm looking for!

Custom dimensions and metrics are part of Universal Analytics. If you are using ga.js you will have to switch to analytics.js to use universal analytics.
If switching cost is too high, you might want to look into Custom Variables in the old product.
-- Updated Answer --
You need to use Custom dimensions in your case. Try something like:
ga('send', 'pageview', {
'dimension1': 'channel'
});
Note that you will need to also setup what the dimension is called as described in the doc i linked to above.

Related

Problem tracking outbound links using TagManager

Hope somebody can help me.
I'm a newby and have a website, using Google Analytics.
I now want to track outbound links from my website to a third party website.
Based on what I found on internet, I have set up tag manager, sas you can see here:
https://saskiahermans.nl/wp-content/uploads/2022/11/TagManager.docx
However, after a few days I can't find any outbound clicks back in Google Analytics, where I'm sure there have been some.
What am I doing wrong? Can anybody please help?
Ok, after debugging it in comments and looking at the actual tracking, here what is sent to GA4 on outbound clicks on the site in question:
en: "click",
ep.link_id: "",
ep.link_classes: "",
ep.link_url: <URL>,
ep.link_domain: <domain>,
ep.outbound: "true",
Well this is plenty.
Now go to your GA4 property, Admin -> Custom Definitions (under the Property) -> Make sure your eps (event parameters) are registered as custom dimensions. Like so:
You probably want to do that for the ep.outbound and ep.link_domain. Don't do it for the link_url. Url can be too high-cardinality for GA4 to handle.
After you're done with defining custom dimensions, give it time to gather data and filter into the custom dimensions (about a day) and go to your Explorer, click the + sign in Dimensions and add your custom dimensions to the list. Now just pull the dimensions and metrics you're interested in into the report and they all should be good.
If you still don't see the dimensions filled, make sure your measurement id in the tracking tid: "G-V24L72RLMM" is the same as in the Admin -> Data Streams. It's a popular mistake when people send data in a wrong analytics property.

What is gtag and why do I have to add that separately from google tag manager?

I find Google documentation around Google Tag Manager (GTM) terrible at helping me figure out which bits go where.
As I understand, GTM requires that you put a <script> snippet on your pages which is supposed to bring in other code snippets, as could be configured by a non-technical user.
I'm a technical user, though. Perhaps that's the problem! I also find it problematic that Google use the word "tag" to refer to either an HTML element tag, like <script>, or their own proprietary use of the word to mean calling a function ("triggering a tag") in another script, also unhelpfully referred to as a tag.
They also have "gtag" which is what - a helper? something that enables you to send general analytics events through the GTM API? The docs simply say:
The global site tag (gtag.js) is a JavaScript tagging framework and API that allows you to send event data to Google Analytics, Google Ads, and Google Marketing Platform.
... but we could already send analytics? What does this add?
For example, I wish to send an e-commerce Purchase event.
I've found that to do this I needed to add a new snippet of code with two <script> tags to the header on the site (thought GTM meant I didn't need to do this?) that sources gtag.js, then I'm able to call the following at the appropriate place in my javascript:
gtag('event', 'purchase', { value: 1.23, transaction_id: 'test' });
Or without it (although this does not seem to work):
ga('require', 'ec');
ga('ec:addProduct', {name: 'test product', price: 1.23})
ga('ec:setAction', 'purchase', { id: 'test_id_1', revenue: 1.23 })
So my question is: when would you use gtag() over ga(), and why can't GTM install gtag?
When would you use gtag() over ga()?
Use gtag if you want to send data to supported Google products other than Google Analytics. As you pointed out, "The global site tag (gtag.js) is a JavaScript tagging framework and API that allows you to send event data to Google Analytics, Google Ads, and Google Marketing Platform.", whereas ga only works for Google Analytics. But (see below), you might decide to never use gtag nor ga and always use GTM.
Why can't GTM install gtag?
It could (you could have a GTM tag inserting some gtag code) but it's beside the point as they are meant to be used as 2 different solutions:
gtag is a purely programmatic tracking tool for sending data and only works with 3 Google products (so far - Analytics, Ads, Marketing Platform - more maybe added in the future), it's made to provide basic out-of-the-box tracking with a simple copy/paste + small lines of code (if needed for customization).
GTM is a tag manager: it can work programmatically BUT requires a minimal configuration of the container via the GTM UI (a default container won't send data anywhere), and can send data to whatever products you want (just need to setup the corresponding tags in GTM), while having a bunch of other features
A few questions to help you choose:
Am I sending data to other tools than Google Analytics/Ads/Marketing platform?
Do I want to use some the extra features GTM offers (UI, version control, templates, debug, environments etc...)?
Is there some tracking that would be heavy to implement via pure custom JS (eg scroll tracking) which GTM can facilitate with its built-in listeners (eg scroll tracking)?
If YES to any of the above, then use GTM
I personally never use gtag, I always replace it with GTM because it's considerably more powerful than gtag.
What Google is doing is progressively replacing all their default snippets with gtag so they only have 1 unified API to maintain and it's an easy copy/paste for users (bear in mind most users aren't tech savy and just need to paste the snippets in into their CMS). Forcing people to use GTM would be too much of a friction as out-of-the-box GTM simply doesn't track anything and people would need to learn & configure GTM, too much work vs a simple copy/paste.
Note: The built-in events don't use category, label, and value. Take care to use the correct keys when sending these events.

Google Analytics API For getting total clicks and impression on element

I am really new to Google Analytics and I had a requirement of tracking clicks and impressions. I followed following link
http://www.statstory.com/tracking-clicks-and-impressions-in-google-analytics/
and sucessfully implemented the same.
Now my requirement is to get the no.of clicks and no. of impressions
to my html page. I am googled for past quite hours but couldnot find
any luck with the same.
Any help would be highly appreciated.
You should really consider implementing Google Analytics Enhanced E-commerce functionality.
Google Analytics Enhanced E-commerce
In regards to answering your question of the API, you should query it asking for events. Namely category, action and label events and apply a filter to only return the data you wish to receive, such as 'Impressions' as a filter for 'Event Action'. That will return all impressions and if you instead change the filter to use 'Click', you'd get all clicks instead.
If you followed the above guide and made it into Universal, then you'd see the calls you set and it is set up in the following way:
_gaq.push(['_trackEvent', 'Banner', 'Click', 'BANNERNAME',1.00,true]);
This bit of code pushes (legacy version) Analytics data in the form of:
_gaq.push(['_trackEvent', 'Category', 'Action', 'Label',1.00,true]);
So, changing the different sections means you change how you define the data and how it will be visible in reports. Category defines the Event Category, Action defines the Event Action and Label defines the Event Label.
Take a look at the core development guide. Also, here you can see all the API calls available: Dimension & Metrics explorer for Google Analytics
I gather that you want to track impressions for banner advertising that is displayed by yourself (i.e. not through an adserver) in your website.
I agree with Mr Sponge that you should upgrade to Universal Analytics. if you want to implement enhanced e-commerce tracking (EEC) you probably want to read about Measuring internal Promotions, which is a feature specifically build for that kind of reporting.
If you just need the raw number of banner impressions and/or need a solution that's easier to implement (but less capable) you can increment a custom metric every time you banner shows up (this is basically a counter, you might want to use it together with a custom dimension that holds the banner name). Click tracking would still be done by events (with similar custom metrics and dimensions). From that data you can assemble a custom report and use a calculated metric for click through rates etc.
Not as good as EEC by a fair margin but much easier to do.

GA Updated to UA however old tracking code is in use

I have a website which has their Google Analytics updated to the Universal Analytics (from the Upgrade Center) however all this while they have been using the Classical Analytics tracking code on the site till date. So that means the implementation is old however, the Analytics end is upgraded to the latest version.
I needed the SO community to comment on the below questions if the tracking code is updated to UA (via GTM - PageView tag)
Will there be any impacts in terms of the way Google collects data?
Will the bounce rate change, avg. session time change?
when you update a GA account to Universal Analytics the tracking code stays the same, you don't need to change it.
If you change the UA don't forget that the data in your old one will not be displayed together.
If you do not change the UA the basic data will still be collected the same way, so your pageviews average number, the bounce rate and session time should stay the same.
What changes is that using Universal Analytics you will have custom dimension and custom metrics instead of custom vars, Enhanced Ecommerce and more complex data. You can see more here: https://support.google.com/analytics/answer/2790010?hl=en

Fake a subdomain in google analytics

I am currently working on a web app that will be running in an iframe on the webpages of our customers. Now i would like to setup google analytics tracking in a way that i that i can easily distinguish one customer from the other. My plan is to "fake" subdomains, even though it is always the same TLD, so that i can setup a profile for each customer, but still have overall analytics as well.
For example my URL is http://www.domain.com/#/3 where 3 is the customer id. Now i would like to see that in google analytics as 3.domain.com.
Is that possible by doing something like this:
ga('create', 'UA-XXXXXX-1', 'domain.com');
ga('set', 'location', 'http://id.domain.com');
or do i have to go about this in another way? My google analytics knowledge is limited to reading the stats and tracking events and pageviews, so maybe there is a whole different and better way to do this - i am open for suggestions.
Thanks!
It will be much better to use custom variables for this purpose. They give you additional segmentation possibilities on any values and metrics you need, such as customer names or IDs (or both ...)

Resources