Send data of one website to multiple views? - google-analytics

Need help setting up Google Analytics tracking code; where data of the website is pushed into two views (blog and admin) separately.
I'll be adding tracking code to both Admin and Blog pages. The situation is like this.
Website: http://example.com/blog
Admin: http://example.com/admin
Blog data goes the "Blog" view only and data related to the Admin-Panel goes to "admin" view. This all has to be done Without using Filters.
<script>
(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-XXXXXX-X', 'example.com');
ga('send', 'pageview');
</script>

Related

why form submit data in Google Analytics and how to remove it?

I wonder why GA is tracking this link:
/de/shop/pizza.html?tx_pizza_basket[action]=addToCart&tx_pizza_basket[controller]=Basket&cHash=fae9b7812f842f543hgf0ac374e9a978ca0
This URL (domain is removed here so it's not the full path) opens the basket with some pizzas added to it :)
I wonder why GA is tracking this exact path and how to stop GA from tracking this sort of form submit URLs.
Here is my GA Code:
# JavaScript für Google Analytics
temp.google.analytics = TEXT
temp.google.analytics.value (
<script>
(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-87654123-1', 'auto');
ga('send', 'pageview');
</script>
)
Regards,
M.
By default, Google Analytics records the value of document.location.href when it is executed. If you don't wish to record the URL parameters for this page, you have 2 options:
Create a set of advanced filters for the reporting view that excludes parameters tx_pizza_basket[action] and tx_pizza_basket[controller]. Additionally set your view's Exclude URL Parameters setting to include cHash
For this particular page, change ga('send', 'pageview') to ga('send','pageview', document.location.pathname)

cross domain tracking not reflected in navigation summary

edit
I edited my post as I narrowed down the issue to just different domains; sub-domains are not an issue.
--
In google analytics there is a navigation summary that shows the previous and next page paths for any page path in the property. This report is under the behavior tab > site content > all pages > navigation summary at the top.
I have cross domain tracking set up but when I go to the navigation summary report I do not see any traversal between domains. The only activity is between subdomains and within the same domain (i.e. www.example.com, a.example.com, b.example.com but not www.anotherexample.com).
I know there is traffic happening between domains because I have done it myself and watched my own session in the real-time tab as I went between two different domains, sometimes including URL parameters to single out my own session.
Why can't I see cross domain tracking in navigation summary?
JS on domain1.com:
(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-XXXXXXX-YY', { //this uses my real tracker ID
'name':'a',
'allowLinker':true
});
ga('require', 'linker');
ga('linker:autoLink', ['domain2.com']);
ga('create', 'UA-XXXXXXX-YY', {'name':'b'}); //Again, uses my real ID for a separate property
ga('a.send', 'pageview');
ga('b.send', 'pageview');
JS on domain2.com:
(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-XXXXXXX-YY', { //uses my real tracker ID
'name':'a',
'allowLinker': true
});
ga('require', 'linker');
ga('linker:autoLink', ['domain1.com']);
ga('create', 'UA-XXXXXXX-YY', {'name':'b'}); //uses my real tracker ID
ga('a.send', 'pageview');
ga('b.send', 'pageview');

Is this the correct Google Analytics tracking code for multiple subdomains and main domains?

This is a two part question:
1) Is my new Google Analytics tracking code correct?
2) With the new code, I noticed a HUGE drop in reported sessions. Is this because the tracking code is more accurate or because my tracking code is wrong.
My Domains (example):
www.domain.org
abc.domain.org
cde.domain.org
www.domain.info
abc.domain.info
cde.domain.info
My OLD Google Analytics Tracking Code:
<script>
(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-99999999-9', 'domain.org');
ga('send', 'pageview');
</script>
My NEW Google Analytics Tracking Code:
<script>
(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-99999999-1', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', [/^domain\.(org|info)$/]);
</script>
Note: I see my second script doesn't have "ga('send', 'pageview');" could that be the reason for the HUGE drop in reported sessions?
Thanks in advance
Answer to your second question, a huge YES! If you don't have a pageview, then you don't have a way to indicate the start of a session.
Your setup looks correct - just might want to check to see if the auto-link domains accepts regex as I have a feeling it doesn't, ie.:
ga('linker:autoLink', [domain.org, domain.info]);
You might have to list them all out.
Don't forget to add your different domains to the referral exclusion list.
New code is better.
You have drop in number of sessions because now your sessions count in a right way.
Now if user jump from domain.org to domain.info it will be 1 session.
With old code it will be 2 sessions.

Appending google Analytics tracking code to existing GA code

i have the following GA code added to my website
<script>
(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-67265472-1', 'auto');
ga('send', 'pageview');
</script>
I created a different property to filter my own ip address from being tracked in Google analytics. The only difference in the tracking code is the below
ga('create', 'UA-67265472-2', 'auto');
Can i simply append this code to the end of the existing GA code or would i need to copy the entire new tracking code into the webpage.
Thanks in advance for your replies
You do not need to include the part that loads the analytics.js file multile times.
However if you simply call create with a different account id a second time you will overwrite the existing tracker and all call will be logged to the second account id.
If you need multiple trackers per page you need to create a named tracker, and send a second pageview call (and events etc.) there:
ga('create', 'UA-67265472-2', 'auto' , 'myTrackerName');
ga('myTrackerName.send', 'pageview');
You can this after your existing code:
<script>
(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');
// default tracker
ga('create', 'UA-67265472-1', 'auto');
ga('send', 'pageview');
// custom name
ga('create', 'UA-67265472-2', 'auto' , 'myTrackerName');
ga('myTrackerName.send', 'pageview');
</script>
To add to the contribution of Eike Pierstorff. When using multiple trackers, it is recommended to start using Google Tag Manager. This will make tracking with multiple trackers much easier.
Especially when you want to track events, custom dimensions, virtual pageviews, ecommerce, etc.

Cross and sub domain tracking with Google Analytics Universal Tag

This is my first question on Stackoverflow. So apologies if I make a mistake...
The challenge: I have a website (main.com), a sub-domain (sub.main.com) and 10 websites that send traffic, back and forth, to the main site and the sub domain. Let's call these sites site01.com, site02.com, site03.com,...,site10.com.
My question: How do I implement Universal Tag so I can do cross-domain tracking between main.com, sub.main.com and site01.com, site02.com, site03.com,...,site10.com.
I found instructions on how to do cross domain tracking for two sites. For example, on the main domain I will add the following code:
**<!-- Universal Analytics -->
<script type="text/javascript">
(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-XXXXXXXXX-X', 'main.com', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['site01.com']);
ga('send', 'pageview');
</script>**
And on site01.com, I will add the code below:
**<!-- Universal Analytics -->
<script type="text/javascript">
(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-XXXXXXXX-X', 'site01.com',{'allowLinker': true});
ga('send', 'pageview');
</script>**
I don't know how to modify the code to include all 10 sites (site01.com, site02.com, site03.com,...,site10.com as part of the cross domain tracking.
Also, in relation to sub-domain tracking, I am guessing that the above code will also capture data from the sub-domain site (sub.main.com) with no issues.
Any help will be greatly appreciated.
Stratos.
You need to add the linker plugin to all of your sites, otherwise you only track visitors starting at the main domain and from there navigating to your subsites. The other way around (originates from site01.com and browses to your main site) would generate a new clientId.
Example (same for all of your sites):
ga('create', 'UA-XXXXXXX-X', 'auto', {
'allowLinker': true
});
ga('send', 'pageview');
// Load the linker plugin and define
// which domains to autoLink.
ga('require', 'linker');
// NOTE: add all your sites here. you can include the
// the site the code is at too if you want to use the
// same array of sites for all of your sites (ie,
// include this from some shared file)
ga('linker:autoLink', ['main.com', 'site01.com', 'site02.com', 'site03.com']);
Use for example the Google Analytics Debugger extension to Chrome to verify that you get the same clientId.
NOTE: You need to click on an achor-link to the other sites for the autoLinker to work, just typing in the URL in your browser won't work.
For implementing this on forms too pass true as a fourth parameter to the ga('linker:autoLink')-call above (ref: https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#autoforms).

Resources