We recommend placing the Kissmetrics snippet in the
<head> section for best performance. The browser loads a page from top to bottom. By placing the snippet on the top of your page, it increases the likelihood that the Kissmetrics code will pick up the activity before the user leaves the page. For example, people may land on your site and then immediately click on something before the whole page has finished loading.
The Kissmetrics snippet is asynchronous, which means it will not delay the loading of the rest of your page. There is no harm to placing it at the top immediately before the closing
One minor (technical) reason for putting the code in the
<body>, the _kmq object will be ready to queue these calls for execution when our script finishes loading. This avoids errors like these:
If your website uses a template to generate pages, enter it just before the closing
<head> tag in the file that contains the
<head> section. This will save you time from manually pasting the code into every single
<head> section of your website.
If you need to, you can still put our script in the
<body> or in the
<footer> tag. It will still work fine.
Updated over 2 years ago