Setting Up Google Analytics to Handle Subdomain Filtering | illumin8 marketing
111
post-template-default,single,single-post,postid-111,single-format-standard,ajax_leftright,page_not_loaded,,qode_grid_1300,qode_popup_menu_push_text_right,vss_responsive_adv,vss_width_768,qode-content-sidebar-responsive,qode-child-theme-ver-1.0.0,qode-theme-ver-16.4,qode-theme-bridge,disabled_footer_bottom,wpb-js-composer js-comp-ver-5.4.7,vc_responsive
 

Setting Up Google Analytics to Handle Subdomain Filtering

Setting Up Google Analytics to Handle Subdomain Filtering

Setting Up Google Analytics to Handle Sub-Domain Filtering

This describes the procedure for setting up Google Analytics to provide filtered reports for multiple sub-domains.

Example:

Primary domain (PD): www.website.com
Sub Domain One (SD1): sub-one.website.com
Sub domain Two (SD2): sub-two.website.com
etc…

Steps:

  1. Create the Google Analytics account for the PD. Ensure that when retrieving the tracking code, the radio button is selected for “One domain with multiple subdomains” in the “What are you tracking?” section.
  2. Insert the tracking code on the website as per usual at the bottom of the code base before the closing </body> tag.
  3. In the profile settings for the PD, go to the “Filters” tab.
  4. Create a new filter and give it a name such as “Track Hostname”
    1. Select “Custom Filter” for “Filter Type”
    2. Select the “Advanced” radio button
    3. Set “Field A -> Extract A” to “Hostname” with value “(.*)”
    4. Set “Field B -> Extract B” to “Request URI” with value “(.*)”
    5. Set “Output To -> Constructor” to “Request URI” with value “$A1$B1”
    6. Set “Field A Required” to “Yes”
    7. Set “Field B Required” to “Yes”
    8. Set “Override Output Field” to “Yes”
    9. Set “Case Sensitive” to “No”
    10. Save the filter.
  5. Create the Analytics profiles for SD1, SD2, and any other sub-domains to be tracked, utilizing the same tracking code for all subdomains as was used on the PD.
  6. In the profile for SD1 go to the “Filters” tab
  7. Create a new filter and give it a name such as “Track Hostname”
    1. Follow the rest of the step 4 instructions to create a replica of the hostname filter applied to the PD
  8. Create a new filter for SD1 and give it a name such as “Include SubDomain”
    1. Select “Custom Filter” for “Filter Type”
    2. Select the “Include” radio button
    3. Set “Filter Field” to “Hostname”
    4. Set the “Filter Pattern” to “sub1.website.com”
    5. Set “Case Sensitive” to “No”
    6. Save the filter
  9. Repeat steps 7 & 8 for any additional sub-domains as required


Important:
Filters are called based on order, so use the “Assign Filter Order” button in the “Filters” tab to ensure that the hostname filter comes before the subdomain include filter.

Filtering of the results should begin to appear in the reports for each profile within 1-2 hours.