Mobile app version of vmapp.org
Login or Join
Berumen354

: Google Analytics: How can I track between http:// and https:// profiles for a domain? I'm trying to set up tracking on a project that I'm working on. The main site is at http://www.example.com/

@Berumen354

Posted in: #Analytics #GoogleAnalytics #Https #Tracking

I'm trying to set up tracking on a project that I'm working on.


The main site is at www.example.com/
The order page is at www.example.com/index.php

Currently they have two different profiles under separate domains:


Main Site: UA-aaaaaaaa-1
Order Site UA-aaaaaaaa-2


This isn't giving me the results I want. When on the order page, I would like to see where on the main page users came from. Also, when on the main page I'd like to see when they navigate away to the order page, right now I can't tell the difference between an exit and order page click.

I'm not even getting the main site as a referrer to the order page.

What am I doing wrong? Should they be under one profile? Or two like I have them. Should I be setting the domain name (_setDomainName)? Should I be using _link() when linking to the order page. I can't find the right resource for what I need.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Berumen354

3 Comments

Sorted by latest first Latest Oldest Best

 

@Samaraweera270

You need to set up cross-domain tracking in Google Analytics.

Follow the linked instructions to do the following:


Set up a master profile for your primary domain without filters.
Create a profile especially for cross-domain tracking and re-use your tracking code.
Modify your cross-domain profile with a filter to show the full domain in your content reports.




In reference to the comment - "my main issue comes from http -> index.php and https -> index.php being recognized as the same page":

Here are some things you can try to differentiate between www.example.com/index.php and www.example.com/index.php (two separate pages):


Rename the https index.php to something else (e.g. index-cart.php). This is probably the best/easiest thing to do.
Rename the http index.php to something else and set as the default document (e.g. default.php). This might be quite easy as your are probably referencing the site root just with href="/"
Alias the https www subdomain to something else (e.g. checkout.example.com). This is just a DNS change, and hopefully a simple change to your config file to point to the new secure alias. This will allow you to do cross-domain tracking exactly as per the Google documentation.
Add a parameter to your links to the secure pages (e.g. href="https://www.example.com/index.php?foo=bar". This would allow you to differentiate between the two index pages in GA. This is not the best option but should be easy to implement without breaking any business logic.


Hope this helps. Please report back on any methods which work for you.



Cross-Domain Tracking in Google Analytics:
* code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html

10% popularity Vote Up Vote Down


 

@Angie530

Virtual page views can be used to aggregate data from multiple subdomains and protocols under a single profile - definitely the easiest way to look at all analytics data gathered for a domain in a single place.

Here's a simple PHP example for tracking virtual page views across subdomains (will appear in reports as /subdomain/uri) or protocol (will appear in reports as /secure/uri):

<?php
$domain = '.example.com';
$uri = $_SERVER['REQUEST_URI'];
/*
* create a virtual page view URI for subdomains other than "www"
*/
if ( $_SERVER['HTTP_HOST'] != 'www'.$domain ) {
$uri = '/' . strtok( $_SERVER['HTTP_HOST'], '.' ) . $uri;
}
/*
* create a virtual page view URI for HTTPS requests
*/
if ( @isset ($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ) {
$uri = '/secure' . $uri;
}
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setDomainName', '<?php echo $domain; ?>']);
_gaq.push(['_setAllowHash', false]);
_gaq.push(['_trackPageview', '<?php echo $uri; ?>']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>


You'll want to change the script to accommodate your configuration if you serve content under "www.domain.com" named "secure" or with the same name as subdomains.

10% popularity Vote Up Vote Down


 

@Steve110

I think you can put both under the same profile. I do the same for http/https combinations. To really track internal navigation you can call the trackPageview part via Javascript as an onClick event on the specific links. There are some resources in the web to handle this (e.g. here)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme