You can use the same JavaScript snippet across different domains and subdomains. For example, let’s say you wanted to measure activity on three of your domains:
client1.yoursite.comclient2.yoursite.comyoursite.3rd-party-domain.comUsing a single API key and the same KISSmetrics JavaScript snippet lumps all data coming from any of these domains into one “site”, allowing you to run aggregate reports on such data.
Our JavaScript stores its identity cookies at .yoursite.com to ensure that we measure the number of people visiting your site, regardless of which subdomain they visit. This allows you to use the same JavaScript snippet (and same API key) across all of your subdomains. This is helpful when, say, you have multiple subdomains set up for different languages:
en.yoursite.comes.yoursite.comde.yoursite.comfr.yoursite.comFurthermore, you can define events common to all of your sub-domains. Let’s say you have a common page across several subdomains, like *.yoursite.com/create-widget. You can record the event for all subdomains, such as “When user views the URL /create-widget, track an event called Created Widget.” As long as all sites are using the same KISSmetrics code (and thus the same API key), the Created Widget event will be consolidated across ALL sites.
That is, visits to en.yoursite.com/create-widget, es.yoursite.com/create-widget, and so on will all trigger the same event “Created Widget”.
This gives you a consolidated view for any particular action, i.e. “Across all of our sites, this particular funnel had a 45% completion rate.”
What it would not do is show you the differences between individual sites (i.e. en.yoursite.com had a 70% completion rate but fr.yoursite.com only had a 20% completion rate). In order to measure that, you would need to also write your own API call which would basically set a property SiteName = en (or SiteName = fr, etc.)
Example:
_kmq.push(['set', {'SiteName' : 'en'}]);
_kmq.push(['set', {'SiteName' : 'fr'}]);
Remember to place this API call after the KISSmetrics JavaScript (in a template file, most likely).
We recommend that you track different domains separately by creating new sites so that you can have data about each domain and not mix up traffic. However, there are scenarios where you may want to install your code on multiple domains. For example, if you use a third-party site to host a knowledge-base, or your e-Commerce checkout system, the visitor can be taken away from your website to the third-party site (a different domain than your site).
Note that with two different domains, there are two sets of KISSmetrics cookies that manage the visitor’s identity. In order to ensure that both cookies have the same identity, you can use our URL API to carry the visitor’s identity from one domain to the other.
Let’s look at an example:
www.yoursite.com, but you use yoursite.3rd-party-domain.com as part of a funnel you are tracking.www.yoursite.com, use the URL API to tag your current KM ID as part of the destination URL: yoursite.3rd-party-domain.com?kmi=bob@bob.comRemember that you can look up your current KM id via a JavaScript function to ensure the right ID gets passed.
Filed under Advanced