Multiple Tracking IDs for Single site without named tracker - google-analytics

In one of my client site, I am seeing multiple tracker IDs without any named tracker. I don't understand why we need multiple tracking IDs for single site?
ga('create', 'UA-XXXXXXXX-1', 'auto');
ga('create', 'UA-XXXXXXXX-2', 'auto');
ga('send', 'pageview')
I'm new to Google Analytics.

You do not need multiple tracking ids for a single site. This is simply an error. The second tracker instance will immediately overwrite the first one, and hits will be recorded for the second property only.

Related

Google Analytics page view tracking

I am using a shiny dashboard with about 20 pages and recently implemented Google Analytics to track page views. The number of pageviews in GA seems to be the same for all pages. I think that once the home page is hit, all other pages are getting hit as well.
I need help to solve this problem. My GA.js script contains the auto script generated while creating an account with GA and this script.
ga('send', 'pageview', {'title': 'Shiny Dashboard','page': '/#shiny-tab-dashboard'});
I have generated similar lines for all the pages with different 'title' and 'page'. Thanks for helping out.
Google analytics does not record hash parameters by default so you would have to a
change your tracking code
https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#allowAnchor
Below are the changes required
Replace
ga('create', 'UA-XXXXX-Y', 'auto');
with
ga('create', 'UA-XXXX-Y', {'cookieDomain':'auto','allowAnchor': false});

Google Analytics not tracking data

We have a total of six websites. Three for two countries consisting of (mobile, desktop and store). Individual tracking code was created for each but after speaking to our developers they put a different code across each site so that we could combine the total set of data of each site in one report.
We have been navigating the sites and placing test orders but nothing is being picked up in GA Dashboard. Not in Real Time either.
Do we need to add each unique tracking code to each site? If So how can these be combined to make one complete report.
Each site has it's own unique code (example)
/* Google Universal Analytics */
(function(i,s,o,g,r,a,m) {i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-01', 'auto');
ga('require', 'ecommerce');
ga('send', 'pageview');
</script>
But our devs have added the same code to all sites. Example
ga('create', 'UA-XXXXXXXX-12', 'auto');
[Partial answer here, as you may need to provide more code samples of your ecommerce implementation if want help debugging that.]
With the same tracking code across all sites, you effectively have a rollup property. But you will need to add specific filters so that can differentiate the traffic from one site to the other, so add a hostname prepend filter at least so that you see which site traffic is from.
If you want to see site specific data with the rollup property, you will need to create individual views for each site, in addition to your best practice views (eg. Test and Raw). Each site-specific view should have an include filter that only shows permits data for that specific site.
If you want to include an individual property for each site, then you will need to give that tracking object a specific name ( Google 'named trackers'), but at least you wouldn't need to create separate views in your rollup property.
To check your hits, use a tool like GA Debugger for Chrome, or check your developer's network tab for the GA requests.

I am trying to set value for custom dimension in google analytics for my website

I'm new to google analytics and i don't realize how make it works.
We have a website and we want to capture the customerId as custom variable in google analytics in order to analyze the behavior of each user with the site.
For this, i start to use google analytics (analytics.js) a few days ago and i created a custom dimension (to know who user access).
The dimension was created with session scope because those values must be sent once per session.
After that, i add the code needed as is explained here:
ga('create', 'UA-#######-1', 'domain.com');
ga('send', 'pageview', { 'dimension1': '<%Convert.ToString(Session["SelectedCustomerID"]);%>' });
I've tried this code and others configurations but google analytics doesn't take the values.
What i'm doing bad? Please suggest me a way to capture the information.

Google Analytics Custom Dimension Not Being Set

I've recently upgraded our site to use Universal Analytics and am trying to get some custom dimensions to work. However, no custom dimension data appears to be logged. Below is an example of my code.
ga('create', 'UA-XXXXX', 'test.com');
ga('send', 'pageview');
ga('set', 'dimension1', '149377');
Do I need to set custom dimensions before sending pageview?
A dimension is sent along with the either a page view or an event. It won't get sent by itself. So you should switch the order of the 'send' and 'set', then look in the network to see the page view call and you should see the dimension as one of the parameters.
Note that you will see the dimension data in google analytics with a delay of a day or so.
I had the same problem, took me a while to find out its cause...
That's correct by the way, that is you must do the SET before the SEND.
Here is the official documentation (see section "Collection"):
[...] Unlike other types of data, custom dimensions and metrics are sent to Google Analytics as parameters attached to other hits, like pageviews, events, or ecommerce transactions. As such, custom dimension or metric values need to be set before a tracking call is made in order for that value to be sent to Google Analytics.
For example, to set a custom dimension value, your code might look like this:
ga('create', 'UA-XXXX-Y', 'auto');
// Set value for custom dimension at index 1.
ga('set', 'dimension1', 'Level 1');
// Send the custom dimension value with a pageview hit.
ga('send', 'pageview');
Cfr. https://support.google.com/analytics/answer/2709828?hl=en

Google Analytics Cross-Domain Tracking with Multiple Trackers

I have a network of sites that are all on different domains and subdomains (domain1.com, sub.domain1.com, domain2.com, sub.domain2.com). Some of them already have Google Analytics trackers installed. Some do not have GA trackers at all.
I'd like to create a way to see a single GA account for the whole network, across domains, without disrupting existing single-domain GA tracking. Additionally, I need to be able to track visits and conversions across sites in the network as though they were a single site. Basically, you could think of it as a totally separate, independent GA account for the network.
I've seen that it's possible to auto-link domains (https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#autolink), thereby enabling network-wide analytics and conversion tracking, but is there a way to do this that won't disrupt the existing trackers already on the sites? Perhaps there's a way to make GA create two trackers with different cookies, one of which is cross-domain?
Ideally, I could give each site's developer a snippet of code to add to their site that would enable the network tracking. Is it possible?
Yes, this is possible. A couple of things to keep in mind though:
I have a network of sites that are all on different domains and subdomains (domain1.com, sub.domain1.com, domain2.com, sub.domain2.com). Some of them already have Google Analytics trackers installed. Some do not have GA trackers at all.
This shouldn't be a problem. Its simple to add a second tracker to an existing page. I'll show you how below.
I'd like to create a way to see a single GA account for the whole network
The auto-linker plugin actually only works at the property level, so these will not only have to share the same account, but they'll have to share the same property. But this is probably what you want.
I need to be able to track visits and conversions across sites in the network as though they were a single site. Basically, you could think of it as a totally separate, independent GA account for the network.
Exactly, you'll create a brand new property just for this purpose, to track all four of these "sites" as a single "site".
Perhaps there's a way to make GA create two trackers with different cookies, one of which is cross-domain?
You can create multiple trackers running on the same site, but they must share cookies. This is because analytics.js only stores the client ID in the cookie, and obviously the client is the same.
For one of your existing sites that already has analytics installed, the code probably looks something like this:
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXX-Y', 'auto');
ga('send', 'pageview');
To add another tracker to that page that is tracking a different property, you can just add a few more lines of JavaScript to the snippet. In this example, you're giving your new tracker a the name t2 so it doesn't interfere with the existing tracker.
ga('create' 'UA-YYYY-Z', 'auto', {name: 't2'});
ga('t2.send', 'pageview');
This creates a new tracker and sends a pageview with the new tracker, but it doesn't set up autolinking. To do that you'll have to modify it slightly (assume this code is for domain1.com):
ga('create', 'UA-YYYY-Z', 'auto', {name: 't2', allowLinker': true});
ga('t2.require', 'linker');
ga('t2.linker:autoLink', ['domain2.com']);
ga('t2.send', 'pageview');
And then for domain2.com you'll just have to change the code slightly to autolink to domain1.com:
ga('create', 'UA-YYYY-Z', 'auto', {name: 't2', allowLinker': true});
ga('t2.require', 'linker');
ga('t2.linker:autoLink', ['domain1.com']);
ga('t2.send', 'pageview');
You don't need to list the subdomains because analytics.js tracks those by default.
In addition to the link you provided, here's some more helpful information about cross-domain tracking:
https://support.google.com/analytics/answer/1034342?hl=en

Resources