Skip to content

Instantly share code, notes, and snippets.

@eskfung
Last active December 24, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eskfung/6767977 to your computer and use it in GitHub Desktop.
Save eskfung/6767977 to your computer and use it in GitHub Desktop.
How KISSmetrics uses the 'identify' API call.
<!-- 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