Skip to content

Instantly share code, notes, and snippets.

@hussainm
Last active January 3, 2016 10:59
Show Gist options
  • Save hussainm/8453597 to your computer and use it in GitHub Desktop.
Save hussainm/8453597 to your computer and use it in GitHub Desktop.
Have KISSmetrics installed on multiple domains? want to see visits and conversion rate for each domain? Now you can this script fires an event whenever a user visits one of your domains. Will showup in KM as an event: Visited yourdomain1.com
// Segment Visitors by hostname
jQuery(document).ready(function(){
var refKm = document.referrer;
var hostKm = document.location.hostname;
// checks if visitor is from a different referrer
if((hostKm.length > refKm.length && hostKm.indexOf(refKm) === -1) ||
refKm.indexOf(hostKm) === -1)
{
_kmq.push(['record', 'Visited '+ hostKm]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment