: How To Properly Setup Google Analytics For Our Subdomain Currently our main website is served without SSL at http://example.com. Our shop is served on a subdomain via at https://store.example.com.
Currently our main website is served without SSL at example.com. Our shop is served on a subdomain via at store.example.com.
Our main site uses the traditional Google Analytics code:
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-XXXXXX-X'],
['_setDomainName', 'www.example.com'],
['_trackPageview'],
['hq._setAccount', 'UA-XXXXXX-X'],
['hq._setDomainName', 'www.example.com'],
['hq._trackPageview']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
Our shop at uses the new Universal Analytics:
ga('create', 'UA-XXXXXX-X', 'auto', { 'allowLinker': true });
// Load the plugin.
ga('require', 'linker');
// Define which domains to autoLink.
ga('linker:autoLink', ['store.example.com']);
ga('send', 'pageview');
Should both the main site URL and the store subdomain's URL be included in the ga('linker:autolink', []); line?
Does the linker section need to be added to the main websites URL code?
Currently all metrics for both sites are showing up under our main websites Google Analytics account, including visits, pageviews, etc. to our shop's URL, which is fine and how we want it to be.
Would like to create a new/separate view where we only see traffic to the store's subdomain. I've created the new view in the account, but I'm not getting any data back at all. How do I need to set up the view to in the settings (such as "Website's URL": We added store.example.com here) or do we need to work with filters?
More posts by @Speyer207
2 Comments
Sorted by latest first Latest Oldest Best
In order to get my view to work correctly, I had to go back to my filter for the new view and add in the "https://" into the hostname. Previously, I only had "store.example.com". Thanks to all who added their very helpful advice!
I'd recommend you run Universal Analytics on both your main site and subdomain under a single property and then create views to separate the sites, as well as a view of everything combined.
The downside of this is you'll lose an historical data. This will allow you track the full funnel + revenue by source and a bunch of other metrics you'll want to collect down the road.
Once both your domain and subdomain are running w/ the same tracking code/property, you'll need to add the autolinker like:
ga('linker:autoLink', ['domain.com', 'subdomain.domain.com']);
Finally you'll have to create separate views if you want to separate subdomain vs. main domain. To do this select "Admin" click the view dropdown and select "Create New View". Go ahead and name the view and select "Create View".
You'll need to create two filters, the first is a prepend URL by hostname. By default GA, only shows what's after your domain (ex. /subdirectory). When dealing with subdomains, you'll want to see the full URL. Here's a tutorial: support.google.com/analytics/answer/1012243?hl=en
The next filter tells GA to only include the subdomain. Select "Filter" then "New Filter". On this screen, select the "Select Filter Type" dropdown, select include only. On the "Select source or destination" dropdown, select "traffic to hostname" and then finally enter your subdomain here.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.