Last active
December 24, 2015 07:59
-
-
Save eskfung/6767977 to your computer and use it in GitHub Desktop.
How KISSmetrics uses the 'identify' API call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- KISSmetrics --> | |
<script type="text/javascript"> | |
var _kmq = _kmq || []; | |
var _kmk = _kmk || 'foo'; | |
function _kms(u){ | |
setTimeout(function(){ | |
var d = document, f = d.getElementsByTagName('script')[0], | |
s = d.createElement('script'); | |
s.type = 'text/javascript'; s.async = true; s.src = u; | |
f.parentNode.insertBefore(s, f); | |
}, 1); | |
} | |
/* Notice the logic here. | |
* 'identify' should be included only when the person is currently known. | |
* If you're not sure who a person is on a given page, then don't include the API call. | |
* Alternatively, this is safe to use if the person is unknown: | |
* _kmq.push(['identify', '']); | |
*/ | |
<% if @current_user and @current_user.current_account.is_a?(Account) %> | |
_kmq.push(['identify', <%= @current_user.login %>]); | |
<% end %> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment