B2K
B2K

Reputation: 2611

Portal Site and Google Analytics Cross-Domain Tracking

I just finished reading about Google Analytics cross-domain linking. All that has done for me is created more questions. I'm hoping to get some help understanding it all.

Our portal site is hosted at http://aq3.processmyquote.com. We create new websites using the first subdirectory as the site name. All secure traffic is directed to https://aq3.processmyquote.com/. For unsecured traffic, we allow our clients to specify an alternate domain name to use for their pages.

We have a single univeral analytics account for the entire site, and views for each client portal. Our issue is that sites which use an alternate domain name are getting tracked as referrals, and we're losing the organic keywords.

Here are some examples: http://www.autoquoter.com, http://www.idriveaffordable.com, http://www.venamex.com

Google's documentation on this states that I should include the autolinker on the main site, and add allowlinker on the secondary sites. How does that work with a web portal? The same tracking code is inserted into each site. Is it ok to just list all the possible domains when creating the tracker?

(function (i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date(); a = s.createElement(o),
        m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g;
        m.parentNode.insertBefore(a, m)
    })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

    ga('create', 'UA-XXXXXX-20', 'auto');
    ga('require', 'linker');
    ga('linker:autoLink',['www.autoquoter.com',
                         'www.idriveaffordable.com',
                         'www.venamex.com']);
    ga('send', 'pageview');

This would be added to all of the sites, since they are all pointing to the same web site. The only difference is that the sites are skinned independently. I'm not sure how I would add the destination ga create code or if I even need to.

ga('create', 'UA-XXXXXX-X', 'auto', {
  'allowLinker': true
});

Upvotes: 1

Views: 263

Answers (1)

B2K
B2K

Reputation: 2611

Well, I've figured this one out on my own. I'm adding my answer here to help anyone else who may encounter the same issue. In the scenario above, it's important to consider that the purpose of cross-domain tracking is to pass the analytics cookie to the next web site.

Let's say that a user landed on http://www.autoquoter.com and enters a zip code to start the quote wizard. The action of that form needs to be secure so it uses the secure domain name, https://aq3.processmyquote.com/... (the full url is omitted for brevity).

In order to pass the analytics cookie to this url, the url needs to be modified to append a _ga parameter to the query string. This is what the google autoLinker does. It just needs a little help to know which links in the page to modify.

<script type="text/javascript">
(function (i, s, o, g, r, a, m) {
    i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
        (i[r].q = i[r].q || []).push(arguments)
    }, i[r].l = 1 * new Date(); a = s.createElement(o),
    m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g;
    m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

ga('create', 'UA-XXXXXX-20', 'auto', { 'allowLinker': true });
ga('require', 'linker');
ga('linker:autoLink',['aq3.processmyquote.com']);
ga('send', 'pageview');
</script>

Notice that we also can include { 'allowLinker': true }, so that the current page would process an incoming _ga parameter if it exists. On each page, I include the domain names of all possible links in that page. So, if I'm on a secure section of the site, I can only go back to the domain name for that client's portal. In this example, that would be autoquoter's domain name. While we could add all the possible domain names, it's not needed. You only need to include the names that would occur in actual links on that page.

ga('linker:autoLink',['www.autoquoter.com']);

I hope that helps someone. If you have any questions about this, add a comment and I'll try to help.

Upvotes: 0

Related Questions