Skip to content

Instantly share code, notes, and snippets.

@dustinlarimer
Created November 30, 2013 20:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinlarimer/7724118 to your computer and use it in GitHub Desktop.
Save dustinlarimer/7724118 to your computer and use it in GitHub Desktop.
Keen.io page view drop-in
// Copy-paste from https://keen.io/docs/clients/javascript/usage-guide/#js-install-guide
var Keen=Keen ||{configure:function(e){this._cf=e},addEvent:function(e,t,n,i){this._eq=this._eq||[],this._eq.push([e,t,n,i])},setGlobalProperties:function(e){this._gp=e},onChartsReady:function(e){this._ocrq=this._ocrq||[],this._ocrq.push(e)}};(function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src=("https:"==document.location.protocol?"https://":"http://")+"dc8na2hxrj29i.cloudfront.net/code/keen-2.1.0-min.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})();
// readKey is not required for this example
Keen.configure({
projectId: "your_project_id",
writeKey: "your_write_key",
readKey: "your_read_key"
});
// Attach your own properties when logging events
Keen.addEvent('pageView', {
page: window.location.href,
time: new Date().toISOString(),
referrer: document.referrer,
agent: window.navigator.userAgent
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment