Google Analytics - Track subdomain AND no subdomain? (xyz.domain.com & domain.com) - google-analytics

When I added the filters to Google Analytics (https://support.google.com/analytics/answer/7476333) to show the full hostname with the subdomain, no traffic was showing up when testing it out on just the primary domain (without www).
What's the proper way to set up filters so that it tracks subdomains and domains without a subdomain?

There is only one filter listed on the linked page. It is a commonly used filter and does not exclude data. It simply prepends the hostname to the requestURI in the GA reports.
If you are trying to track a subdomain of the primary domain and the primary domain, having tracking for the same Property on both with the cookieDomain set to auto (which it is by default)and the filter applied should be all that is needed.
If you are trying to track a primary domain and subdomains of a different domain, then if you are are trying to preserve referral and session data across the two, then you will need tracking for the same Property on the primary and subdomains, configured for cross domain tracking setup as per the article and the filter applied.
One weird issue I have come across (and it happens really randomly without rhyme or reason), is a view not reporting data, until the Save button on the view settings page has been clicked.
Usually the three most common issues i see are:
1) Tracking for the same property as the primary domain not being installed on the subdomain(s)
2) Tracking for multiple Properties being installed, setup with incorrect configuration for multiple trackers.. which can cause all hits from all trackers to get sent to just one Property instead of all Properties
3) Incorrect filters applied or incorrect filter order. Filters run in the order they are applied/added to a view. The order of the filters, needs to be set in the Filter table for the particular view.
Example of incorrect filters -
a View with a hostname filter to include only the Primary domain hostname, that also has the above filter applied, will not show any data for the subdomain(s) only the primary domain.

Related

Google analytics - allowed hosts

I'm seeing entries in my analytics data for pages that no longer exist.
This could be developers looking at legacy versions of a site, it could also be triggered by something like wayback machine.
Is there a way to either identify what hosts an analytics tracking pixel is being triggered on, or restrict analytics to only execute on either a set of domains/hosts or ip address
LinkedIn campaign manager and Hubspot have features where you can tell the tracking script what domains to include/exclude
This is different from excluding ip addresses when setting up filters
Thanks
you can use filters on view level (Universal Analytics, not GA4) in order to exclude or include specified domains to ga data. Keep in mind, adding or removing filters work for new collected data only. Maybe add an additional view, so one view contains all data (based on your ga setup). With this solution GA collects data but will not show the data in the filtered view.
In order to fire the ga tag on a specified domain, specify the host in the trigger in Google Tag Manager, if it is implemented on page. This setting the tag will not be fired on other domains.
If there is no Tag Management on the page, you can check the domain using js before firing the ga script.
Keep in mind, that it is possible to send data to GA without fireing the GA tag by using Measurement Protocol. So if a lot of spam data appears in the interface, may add additional filters to exclude this data aswell.

Google Analytics - View filter not working

I have a Google Analytics account for a mobile app (it is actually a .NET Desktop application that is hooked up to the API for mobile apps).
To get rid of referral spam etc, I've set up an include-filter for my view (see pic below). The filter checks the Application Name field and should include only traffic that has this field. In my application, I always call the GA API with this application name.
Now, the problem is that this filter seems to not work when set as a View Filter (to filter out incoming traffic). Even though I set this filter up several weeks ago, I still get referral spam traffic that does not have a valid Application Name. But if I apply the exact same filter to my reports, it actually filters out the spam.
Does anyone here have an idea of why the filter works when filtering out reports, but not as a view filter?
I solved this by including a hostname filter. The filter is set as:
Include -> Hostname -> Filter Pattern "(not set)".

Google Analytics: filter to show full URI in reports, but only for subdomain

I need to track a subdomain under an existing property that is already tracking my domain. From the user's perspective they look like one site and I need to see the flow of traffic between them, so they should ideally be under the same property.
I'm trying to configure things so that I can tell the difference between data for the domain and subdomain in my reports. I've done some research and most of the instructions that I've found give the solution of a filter to show the full path of all URIs in your reports. But that would mean that the new data for the main domain no longer matches up with historical data: it would make it more difficult to compare to the past and would require me to update all my destination goals.
I would like to only show the full URI for the subdomain, so the data for my main domain stays consistent. I'm sure that adding on a subdomain to an established website is a pretty common scenario and I'm not the only person who has this issue.
I did find one set of instructions for showing the full hostname for just one subdomain: http://www.ericmobley.net/guide-to-tracking-multiple-subdomains-in-google-analytics/
I set up the advanced filter as he specified, with my subdomain in brackets as the expression in the hostname field (screenshot: http://i.stack.imgur.com/5zc6c.png). When I checked my reports to test this, the real-time reports were showing the full path of traffic to the subdomain but not the main domain. The subdomain URIs were displaying in brackets. However, in the Behaviour reports the hostname wasn't showing up for either site and there was no distinction between traffic to the domain and subdomain.
What am I doing wrong here? Is it possible to create a filter that does what I want?
Advanced filter fields use regex, so field A should look like this
(support\.whatever\.org\.au)
Note that this filter includes ONLY the support sub domain.

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).

can I use the hostname as a dimension in google analytics?

Considering a site that exposes a dynamic range of hostnames... Is there a way to use the hostname as a dimension in reports?
There are docs related to hostname, but not doing what I want. I've seen things on filtering by hostsname in a profile, or having a profile filter that adds the hostname to the path GA uses. I would rather use the hostname as a secondary dimension in reports.
One option I have is to add the hostname as a custom variable. This seems wasteful though, as each request is only allowed 5 custom variables and the hostname is already transfered as part of the google analytics beacon. I see the hostname included in the request to __utm.gif as querystring parameter utmhn.
Yes.
Any report's secondary dimension selectors will allow you to set hostname as a secondary dimension.
You can even access it as a primary dimension by navigating to Visitors->Network Properties->Hostnames (or, in the new GA, Visitors->Technology->Network->Hostname).

Resources