Google Tag Manager referral hostname - google-analytics

I have 2 hotel websites on their own domains with individual GA tracking codes which both use the same booking engine, also on a standalone domain. The booking engine can only use 1 GTM container, so both hotel websites also have to use the same GTM container with the aim to track the ecommerce.
I've used a page view tag with a hostname lookup variable which pushes the correct GA tracking code on each website which works fine. Problem is tracking the ecommerce.
I've tried using a URL fragment so if they are on www.bookingengine.com/hotel1 then it would assign the correct GA tracking code, but that doesn't work.
What I need is the tag manager to know the referral hostname if you are on the booking engine and change the GA tracking code used dynamically, so it matches the correct referral website. Is this possible?

You can get the Referrel-Hostname by using the Browser-API document.referrer. This gives you the Page the User came from.
Take this as an Javascript Variable and build a Trigger based on the Variable:
{{referrer}} regexp abc.com

Related

How to create a Google Analytics report on a specific query string?

I have hunted around a bit and only found how to setup the site search parameter in a site's admin section. This is not what I want. Also looked through some Google Search Console videos - no go.
Given a URL, https://somesite.com/redirect/?redirect=https://gofundme.com/somecampaign/.
As some background, what I have setup here is a simple page that says "Loading..." and is used for external links I want to track analytics on, from platforms that I may not have access to the link's analytics. For example: https://gofundme.com/somecampaign.
Rather than having a redirect setup on the page itself, I injected custom JavaScript through Google Tag Manager that records analytics data in Google Universal Analytics (anyone want to recommend how to do this in G4A?) then performs the redirect.
My question is, in Google Analytics, how do I setup a custom report where the query string parameter = redirect and/or the specific page URL?
Thanks.

Problem with traffic source and virtual events. Google Tag manager Analytics

I'm having some troubles with GTM and iframe.
My website has a button that redirects to Shore for booking. On mobile a new tag opens.
I can see at Content on Google Analytics:
/
/bookings/my-website/services?layout=nolayout&locale=es&origin=nolayout&theme_color=1f1f1f
/virtual/select-service
/virtual/booking-success
The problem is that I loose the medium. At the begining is Organic/cpc...
But on step 2 it creates a new sesion (none)/(direct). It's false.
Could you help me keep the medium on the /virtual/{{Event}}?
My GTM configuration is:
Trigger:
Custom Event
Event name: .*
Some custom events: Event -> matches RegEx -> (select)|(success)|(booking)
Tag config:
Track Type: Page View
Enable overriding settings on this tag (checked)
Fields to Set:
Field name: Page -> value: virtual/{{Event}}.
Tag firing options:Once per page
It's strange because medium is ok when the reservation is through Facebook or Instagram. It just fails on the website.
Thank you!
This is very likely an issue with the changing of domains as users navigate to the widget. Unless cross-domain tracking is specifically set up, when a user visits Site A and then Site B, and both sites have the same Google Analytics (or GA through GTM) tag, the visit to Site B will record a source/medium of either direct/none or {Site A}/Referral, depending on your referral exclusion setup. This is regardless of the source/medium was recorded for the visit to Site A.
In your scenario, hit 1 (/) is your own domain, and then (I'm guessing) hits 2-4 are on Shore's domain (probably connect.shore.com according to the help page).
To remedy this, you need to setup cross-domain tracking. The official guide for GA through GTM is here, but another excellent resource is Simo Ahava's blog. Note that cross-domain linking needs to be setup with every page in the funnel. This means if you are using GTM to deploy GA for the booking virtual pageviews, but are using the direct embed code to put GA on your own site (step 1), with analytics.js, then you need to follow the guide to enable it there.

Google Analytics with Google Tag Manager not reporting properly on subdomains

I have a site with 3 subdomains with the same Google Tag Manager and Google Analytics tracking ID. I created 3 views on the property, I applied the proper inclusion filters so I can focus each view on its counterpart subdomain.
GTM is firing GA on the three subdomains and the GA debugger is showing that it is tracking (I tried recording and it worked, I tried GA plugin and there are no errors).
The problem: One of the subdomains is reporting everything (all subdomains)! Even with the proper inclusion filter in place. The 2 other subdomains are reporting nothing.
Note that my inclusion filter is equal sub1.example.com (and the same view is reporting on sub2.example.com and sub3.example.com)
I spent 6 hours so far, reading documentation and trying different options to no avail.
Why would be a filtered view for one subdomain show stats for the other subdomains? Why would the other subdomains show nothing? Would this be related somehow to GTM?
GTM id is the same across the domains and not duplicated and matches the account number
GA snippet is not included on the pages and the id is double checked
The three subdomain settings are exactly the same with only the inclusion filter being different
Make sure that you disable UserId Tracking when you create a View.
Enabling UserId Tracking will exclude all analytics without it being set.

Tracking traffic of individual microsites Google Analytics

I have a web site which has many microsites.
I want to use Google Analytics to track the traffic of each individual Microsite as opposed to tracking traffic of the whole site?
I have looked at Google Tag Manager, but I am not sure if this is the right solution - how can this be done?
Thanks
There's two basic ways in which this can be done:
If you don't care about inter-microsite traffic, you can just create a different GA property for every microsite and use Google Tag Manager to create your GA tracking tag with the right property ID depending on the hostname (using a lookup table variable, for example).
If you want to be able to see traffic flow between your microsites (i.e. not have a visitor navigating from one site to another show up as a referral but as the same session), then you should use the same GA property for all sites and set up cross domain tracking. Then inside your GA property, you can set up different views based on the hostname dimension of the hits.

Can I use Google Tag Manager to collect analytics from mulitple domains?

The set-up:
1 site, 2 domains: = mysite.com and mysite.co.uk
These 2 domains use DNS to point to the same site (IP).
There is 1 snippet of Google Tag Manager (GTM) code just after the opening <body> tag of the site (every page).
In the GTM container, I have added both domains on the "Container Settings" page.
There is one Google Analytics (GA) account which only contains the .co.uk domain. (An analytics account can only contain 1 domain.)
A tag has been set up in GTM with the type of Google Analytics and it has the UA code from the 1 GA account added.
A rule has been added to fire on all pages
Now, I don't care whether someone visits via .com or .co.uk, but I want to capture combined analytics for both. My questions is, with the way I've set things up using GTM, will GA save data for both domains ie mysite.com and mysite.co.uk, or do I need to set things up another way to achieve this? Ideally, I don't want to go down the forwarding route i.e. forward all traffic from .com to .co.uk.
First a bit of pedantry: Google Tag Manager cannot even collect informatiom from a single domain (it's not a tracking tool). And while you can only enter one domain in Google Analytics that domain setting serves no actual purpose; a Google Analytics account can track multiple domains in different "properties" (porperties are sections in an account that each have a unique id) or in a single property via cross domain tracking. Cross Domain tracking is used if you want to treat multiple domains as a single presence on the web (i.e. if you have a website and a shop with different domains, they still belong together).
Now, the way you have set things up data will be collected from both domains. There are at least two caveats:
1) If users can switch between domains inside a session (go from .com to .co.uk and back) their sessions will be interrupted and Google Analytics will register multiple visitors (that's because users are tracked via cookies which are domain specific). To avoid that you'd need to set up cross domain tracking (and how you would do that depends on if you are using Universal Analytics or asynchronous code. Look at your tracking code, if it contains a line that starts "ga("send"...." your are using analytics. If it contains lines that start with _gaq.push you use asynchronous code).
Cross domain tracking documentation for UNiversal Analytics (analytics.js)
Cross domain tracking for asynchronous code (ga.js)
2) By default Google Analytics tracks only the path, not the domain. If pages on both domains have the same path they will be displayed in aggregated form in the reports, that is if you have an index.php on both pages the visits for both will be added up. Maybe that's just fine with you, if they show the same content in any case. Else you'd either have to use "hostname" as a second dimension (which is not a sticky setting, you would need to re-apply that every time you switch to another report), or you create a filter on your view that includes the hostname in the reports.
Those caveats are relevant because data will show up in any case and will look perfectly okay even if it's not (even if you decide that those two things do not bother you you need to take them into account when you interpret the data).

Resources