Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to handle https, http, www, and no www with Google analytics

I have a website that I'd like to track properly with Google Analytic. The main site is just example.com. There is also a store setup, so we are using https on part of the site. My question is: Do I create different profiles for each variation of the domain name? If yes, do I embed all four of them one after another?

URL combinations we have:

http://example.com
http://www.example.com
https://example.com
https://www.example.com

Thanks

like image 250
Christina Rule Avatar asked Aug 18 '13 02:08

Christina Rule


People also ask

Does http or https matter in Google Analytics?

Also, the use of an HTTPS site makes Google Analytics more effective. This is because the security data of the website that referred to you are saved with the use of HTTPS – it's not with HTTP sites. With HTTP sites, referral sources will just appear as “direct traffic”.

How do I change from http to https in Google Analytics?

To do this click into Admin under Google Analytics and then your property settings. Scroll to the bottom and click on “Edit” under Webmaster Tools Settings. Choose the new site with https protocol and hit Save.

Can you use Google Analytics on a website you don't own?

You can't see Google Analytics data for another website unless the person who owns the website gives you access, or shows it to you. To get an estimate of how many visitors a website you don't own gets, you can look at other metrics. Such as: How many likes and follows their Facebook page gets.


1 Answers

If you want to keep separate URLs, setup cross-domain tracking, using this.

  • Setup a master profile, with no filters.
  • Setup a cross-domain profile, per above.

Generally no, you don't want different profiles for each of them, as you won't be able to then measure traffic thru the entire site. Each profile is it's own discrete view of the data. If you create separate profiles you won't be able to report off a single, contiguous session on your site.

Also, it's a good practice to setup your web server to always redirect to the main URL that has the certificate... in your case have MySiteExample.com redirect to www.MySiteExample.com.

Finally, this kind of question is actually better asked here: https://webmasters.stackexchange.com/


EDIT:

To clarify on the http and https, you don't need to do anything in the property / profile configuration, since they are the same domain. Further, the script that you include for Google Analytics handles avoiding mixed mode (https and http on the page). See this: https://developers.google.com/analytics/devguides/collection/gajs/#quickstart. Specifically, the following javascript line handles delivering the script via https or http, depending on whether the page was retrieved via http or https. In processing, google analytics doesn't care if you are using https or http.

ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
like image 89
RobM Avatar answered Oct 23 '22 20:10

RobM