Kênh 360 Công Nghệ Kênh 360 Công Nghệ

Trang chủ - Thiết kế web - Google - Google Analytic Cross-Domain Tracking

Google Analytic Cross-Domain Tracking

Chỉ mục bài viết
Google Analytic Cross-Domain Tracking
Google Analytic Cross-Domain Tracking
Google analytic Cross-Domain Tracking 3
Tất cả các trang

Cross-Domain Tracking

This document describes a variety of ways to use cross-domain tracking customizations when you want to collect visits to multiple domains in a single profile—as if they were a single site rather than two separate ones. It also covers how to track portions of a website, such as sub-directories and iFramed content. If you are unfamiliar with the general process of cross-domain tracking, see Domains and Directories in our Help Center.

  1. Introduction
  1. Tracking Scenarios
    1. Multiple Domains & Sub-Domains
    2. One Domain & Its Sub-Domains
    3. One Domain & Sub-Directory of Another Domain
    4. iFrame Content Hosted on Another Domain
    5. A Single Sub-Directory
    6. Two Directories on the Same Domain
  1. Key Components to Cross-Domain Tracking
    1. Profiles
    2. Cookies: Necessary to Transferring Visitor Data
    3. _setDomainName('none')
    4. _setDomainName('yourDomainName')
    5. _setAllowHash(false)

Introduction

A default setup of Google Analytics is designed to track content and visitor data for a single domain, such as www.example.com.

However, suppose you want to use Analytics for more complex situations, such as tracking:

  • Subdomains—all visitors to both dogs.example.com and www.example.com, with data for both showing in the same report profile
  • Subdirectories—only visitors to the www.example.com/dogs subdirectory in a separate report as if it were a single site
  • 3rd-party shopping carts—visitors to your online store and to your shopping cart hosted on another domain
  • Top-level domains—all visitors to two domains that you own, such as www.example-petstore.com and www.my-example-blog.com, with data for both showing in the same report profile
  • IFramed Content—visitor and pageview data for content in an iFrame of another domain.

In any of these cases, you'll need to do some customization to the tracking code in order to correctly track visitors. Before doing this, it's a good idea to read how Domains and Directories are treated in a default Analytics installation.

Tracking Scenarios

This section covers a variety of tracking scenarios, ordered by the most popular methods.

Tracking Across Multiple Domains and Sub-domains

In this scenario, you might want to track two unique domains and one sub-domain. For example, suppose you have an online store and you also want to track visitor and campaign data to your blog.

Tracking Across Multiple Domains and Sub-Domains

The following shows key tracking code customizations for three example URLs.

  • Online Store Domain: www.example-petstore.com

    Asynchronous syntax

    var _gaq = _gaq || [];
    _gaq
    .push(['_setAccount', 'UA-12345-1']);
    _gaq
    .push(['_setDomainName', '.example-petstore.com']);
    _gaq
    .push(['_setAllowLinker', true]);
    _gaq
    .push(['_setAllowHash', false]);
    ...
    <a href="http://www.my-example-blogsite.com/intro.html"
    onclick
    ="_gaq.push(['_link', 'http://www.my-example-blogsite.com/intro.html']); return false;">See my blog</a>
    ...
    <form name="f" method="post" onsubmit="_gaq.push(['_linkByPost', this]);">

    Traditional (ga.js) syntax

    The only links or form data that you need to customize are those that point to www.my-example-blogsite.com. This is not required for links to the sub-domain of this site, since the _setDomainName() function defined .example-petstore.com as the domain to enable cookie access for any other subdomains.

  • Online Store Subdomain: dogs.example-petstore.com

    Asynchronous syntax

    var _gaq = _gaq || [];
    _gaq
    .push(['_setAccount', 'UA-12345-1']);
    _gaq
    .push(['_setDomainName', '.example-petstore.com']);
    _gaq
    .push(['_setAllowLinker', true]);
    _gaq
    .push(['_setAllowHash', false]);
    ...
    <a href="http://www.my-example-blogsite.com/intro.html"
    onclick
    ="_gaq.push(['_link', 'http://www.my-example-blogsite.com/intro.html']); return false;">See my blog</a>

    <form name="f" method="post" onsubmit="_gaq.push(['_linkByPost', this]);">

    Traditional (ga.js) syntax

    Links back to the primary domain do not need configuration because the sub-domain shares the same cookies with the primary domain.

  • Blog Domain: www.my-example-blogsite.com

    Asynchronous syntax

    var _gaq = _gaq || [];
    _gaq
    .push(['_setAccount', 'UA-12345-1']);
    _gaq
    .push(['_setDomainName', 'my-example-blogsite.com']);
    _gaq
    .push(['_setAllowLinker', true]);
    _gaq
    .push(['_setAllowHash', false]);
    ...
    <a href="http://dogs.example-petstore.com/intro.html"
    onclick
    ="_gaq.push(['_link', 'http://dogs.example-petstore.com/intro.html']); return false;">See my pet store</a>
    ...
    <form name="f" method="post" onsubmit="_gaq.push(['_linkByPost', this]);">

    Traditional (ga.js) syntax

    This configuration sets the domain name to the top-level domain for the blog site. In this way, if you later add any sub-domains for the blog site, that sub-domain will be able to share cookies with its parent and you will not need to set up special linked calls between them. However, you still must use the _link() and _linkByPost() methods for any form or links to www.example-petstore.com.



Lần cập nhật cuối ( Thứ tư, 09 Tháng 3 2011 14:05 )  

Kênh 360 công nghệ

  • Nổi bật
  • Tin mới
  • Game mới
  • PrestaShop Guide
  • PrestaShop

Có thể bạn quan tâm

Download nhiều nhất

11/12
Download PES 2011 - FIFA 11
693
18/12
binkw32 dll
175
18/12
TeamViewerQS
49
English French German Japanese Korean