Google Analytics Property vs. View for app vs. website - google-analytics

I have a website (WordPress) that is set up at http://mydomain.com
I also have an app (meteor) that lives on a subdomain http://app.mydomain.com
I would like to track these two separately. I already have the tracking code on the WordPress site. Do I add the app as a new property or a new view?
When I tried to add the app as a separate property, in the tracking code I see this line:
ga('create', 'TRACKING_CODE', 'mydomain.com');
It seems to be that GA only cares about the top domain level?

Create one property for mydomain.com and two views: one for http://mydomain.com and one for http://app.mydomain.com. For the two views, create a filter that includes only traffic to that domain. E.g. Include Only Hostname (whatever).
Regarding this:
ga('create', 'TRACKING_CODE', 'mydomain.com');
Leave it as is. The mydomain.com allows you to track across subdomains, which is what you're trying to do.

Related

What to do with Google Analytics for domain and subdomain which will be moved to subdirectory?

I have a Wordpress site (example.com) and subdomain (sub.example.com). They have separate Wordpress dashboards and work like 2 separate websites. 2 different Google Analitycs Tracking IDs set up for them, so we have 2 different Google Analytics accounts and 2 different properties respectively. Now we redesigned both websites and want to move subdomain to a subdirectory, so it will look like this: sub.example.com --> example.com/sub, but they still have 2 separate Wordpress dashboards.
My question is, what should I do with Google Analytics? Should I put the domain GA tracking code on subdirectory website as well? As the initial idea behind making moving subdomain to subdirectory was for SEO boost and consolidation of traffic.
I also would like to start using Google Tag Manager to implement GA tag.
Would appreciate some input on this as I'm really confused Thanks!
You have to use 'google analytics' separately for both the websites as header is different in both the websites.

Is it possible to have google analytics users that can only view pages within a subdirectory?

Have setup a WordPress multisite which is using the same GA tracking ID to make things much simpler in our Google Analytics Dashboard (plus there is like a limit of 50 individual IDs you can track with one account I think?).
WP multisite is setup on subdirectories and not subdomains, e.g.
mysite.com.au/sitename1
mysite.com.au/sitename2
Anyway, some of the admin from the sites want access to the Google Analytics for their site. Upon investigating, I found that they would be able to access stats for other sites (besides their own) within the multisite. We definitely do not want this.
Is there a way to limit a GA user account so that they can only view pages within their own site (a fixed subdirectory), for example:
mysite.com.au/sitename1
and not be able to view information from any other site subdirectories? I'm a beginner to Google Analytics and I heard I might be able to setup particular views, goals or campaigns to achieve this.
You can do this with Views (bad thing - each property can just have 25 Views)
You find Views in the right column of the Admin page. Add a new View through the Dropdown. You can now set a filter to this View (/sitename1).
After this click on "User Management" in the View column and give the User you want to have there access.

How to track single folder traffic in Google analytics?

I have forum directory on my website. That sub directory is located on http://www.mobilestore.pk/forum I was wondering that how can I track forum traffic only as a separate property in Google Analytics without filtering it from the whole traffic of the website. So I can show the trends of forum to Moderators or Editors.
I don't recommend using a property to break out traffic on the same domain. It's better to use a new view with a filter. Be sure to keep a view that is unfiltered.
If you do decide to use a separate property, you will need to modify the code in all the page templates used in the /forum path to use a different UA tracking ID.
You can add a 2nd tracker for just the forum.
As per Google:
"In some cases you might want to send data to multiple web properties from a single page. This is useful for sites that have multiple owners overseeing sections of a site; each owner could view their own web property."
This exactly fits your scenario
See https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#multipletrackers

Google Analytics Tracking across subdomain and one specific subdirectory

I've gone through all the GA documentation and understand pretty well how to track across subdomains. I need to do something slightly different. My sites are moving from subdomains to subdirs onto one subdomain (www). From site1.domain.com to www.domain.com/site1, etc. Previously, there was nothing on www, only the subdomains, which all have their own tracking id, ie. 12345-2, 12345-3, etc. Both sites (old and new) will be live at the same time, so we need to aggregate and track across the subdomains (got that down, w/ all the filters needed) but also track/link only a specific directory on the www to each of the old subdomains. One kink is that while all the sites will map easily from site1.domain.com -> www.domain.com/site1, one special site - online.domain.com will map to www.domain.com/ with no subdir.
I figured I could solve the subdir issue by only placing the code for each property id on the respective subdir pages. I.e. site1=12345-2, and all the pages in /site1 get that code. For the online.domain.com site, the property-id specific code would have to be added to about 20 other subdirs, like /about/, /contact/, etc. Is this correct or kludgy? And i might even add new profiles that filter for subdir as a backup measure. But the issue I am having is this, I really want to track them as separate sites so that referral, time on site, etc metrics are specific to each subdir (site) and not shared across all the subdomains (which I think what subdomain cross tracking enables.) So I thought the solution was _setCookiePath, but can I use that on one subdomain (www) while cross-tracking and not the other? Because the old site won't have /site1/ as a valid path. Logically, is this something I even can do? Won't setting _setCookiePath on one side defeat the purpose of cross subdomain tracking?
I am confused about the usage of _setCookiePath when tracking subdirectories. When do you use setCookiePath and when do you just filter the data via subdir with profiles? The documentation says if you use _setCookiePath you need to disable tracking at the root level. What is the issue there? (I don't think this would work for me because I also need to track other top-level dirs like /about/). Also in another rollup account I want to track all the sites with one property id and then use filters to set up unique profiles for each subdir/site, eventually retiring the old method that uses multiple profile IDs. But I want to track my subdirs as separate sites with separate cookie info so that a referral to www.domain.com/site1 is not shared with www.domain.com/site2 - is this impossible with my requirements? More importantly, visits and uniques need to be segmented by subdir. A user that comes to /site1 then goes to /site2 needs to be a new visitor on /site2.
Update: did I totally overthink this? Since users probably wont be moving between old and new sites can I just add the same tracking property id to both sites w/o crossdomain tracking? That would help me consolidate old and new, but I still have the issue of how to track all the new subdir sites as different sites that don't share cookie info.
It sounds to me like you are moving from a more complex set up to a far simpler one.
If your new domain structure is:
www.site.com/one
www.site.com/two
www.site.com/three
www.site.com/four
Then the standard default Google Analytics code snippet will work. IE Without cross domain tracking, just select 'single domain' when setting up your new profile.
The only issue i can see is that current your data is stored in different profiles. Using this new setup all data will be stored in one single profile. However using the 'Page' metric you could create advanced segments to separate traffic visiting 'Pages' beginning with '/one' for example. Or you could create multiple filters with Page based filtering to separate the traffic from 'www.site.com/one' from 'www.site.com/two'.

Google Analytics - only track traffic to a folder of the site

I want to track traffic for mysite.com/current-campaign/ and careless about traffic on mysite.com in general.
Is it ok to place the GA tracking code in the files inside the /current-campaign/ folder or does it HAVE TO be in the root of the server for tracking to work?
GA will only track on the pages you actually put the tracking code on, regardless of where the page is located (unless you start messing with things like domain settings or filters etc..).
So IOW yes, it is okay to do that. If you don't have tracking code on mysite.com/somePage.html then it's not gonna track that page (though it might show up as the URL in some reports like referring URL or exit link or whatever, same as any other page you don't track)
In Google Analytics, you can add a filter to the profile and filter all but the chosen directories. Go to Analytics Settings > Profile Settings and look for "Add Filter" link.
In addition to Crayon's answer, you can limit tracking to a subdirectory by using _setCookiePath() function in your tracking function. See Analytics documentation on single subdirectory (note the link anchor is not resolved to a correct header, at least for me).
This is advised in the documentation to use when you only want to track a subdirectory and avoid clashes with Analytics trackers possibly in use in other subdirectories.
I work for a department in a large university.
The department's web page resides at www.some-uni.com/department-name/.
I only have FTP access to the sub-folder /department-name/ and nothing else on the site.
It was quite easy to get Google Analytics to track traffic within the subfolder /department-name/, ignoring the rest of the site. All I did was create a profile in GA, setting the default url to www.some-uni.com/department-name/. I then pasted the tracking code into the pages I wished to track.
It took about eight hours for anything to show up in GA, but after that it worked just fine.

Resources