InfoHeap
Tech tutorials, tips, tools and more
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search
  • Home
  • > Tutorials

How to set up google analytics profiles for domain and sub-domain tracking

By admin | Last updated on Mar 21, 2016

[Update Feb, 2016: This article is based on old version of Google analytics and is now deprecated. Please visit Google cross domain tracking page for latest documentation.]

Google analytics can be used to track a domain and its one or more subdomains. This is pretty useful if you are having one or more subdomain sites in addition to main site. Here are the steps to set up google analytics profiles for subdomains.

  1. Go to google analytics admin page and create new account as shown below.
    google-analytics-new-account
  2. Next screen will show tracking id and few options along with subdomain on-off option. Click on it to turn it on.
    google-analytics-subdomain-on
    After turning it on you should see this kind of code:

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
    _gaq.push(['_setDomainName', 'infoheap.com']);
    _gaq.push(['_trackPageview']);

    Please note the presence of _setDomainName

  3. Click save and proceed to the property we just created. It is created with a default profile. The profile will show the analytics data for the main domain infoheap.com and all its subdomain if nothing is done. We need to add a filter so that the subdomain data is not captured by the main profile.
  4. Click on new filter. And create a sobdomain include only filter as show.
    google-analytics-filter-include-only-hostnameThat’s it. Now this profile will only contain analytics data for infoheap.com and not its subdomains. To create a subdomain profile, create one more profile and a subdomain hostname include only filter for it.
  5. In case you are using wordpress and google analytics plugin by yoast, you can enter subdomain for tracking purpose in plugin settings as shown below:
    google-analytics-wordpress-plugin-subdomain-tracking
  6. Please note that each profile can have any number of filters and each filter can have any number of profiles. In case you need to view/manage your filters later,  you can go to your account page (Admin home -> account name) and click on filters. This is how the list will look like:
    google-analytics-filters-list

How to check is all profiles are working fine

To see if profile and filters are working fine follow these steps:

  1. go to real time reporting page of that profile and click overview sub option.
  2. Visit that domain or subdomain preferably on a specific url from a new browser window. The page you are viewing should show up in real time tracking in few seconds. If not then you need to review the setup.
    google-analytics-real-time-subdomain-tracking

Suggested posts:

  1. HTTP cookie and sub domains
  2. How to use google custom search for wordpress site
  3. Using Google analytics SDK v2 for android app real time tracking
  4. PhantomJS – how to skip Google analytics code when fetching a web page
  5. How to become Google verified author of your wordpress blog using Google+ profile
  6. www vs non-www domain which is better for your site?
  7. How to select a domain name for your site
  8. How to migrate your site from one domain to another
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Tutorials

Follow InfoHeap

facebook
twitter
googleplus
  • Browse site
  • Article Topics
  • Article archives
  • Recent Articles
  • Contact Us
  • Omoney
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries

Copyright © 2023 InfoHeap.

Powered by WordPress