##Honeycomb
Paste the following snippet into your javascript file to set up tracking for your website. Alternatively, nest it between <script> tags </script>, and paste it right before the closing </body> tag of any pages you want to track.
“‘ <script> var unique_key = <insert unique key here> var endpoint = “localhost:3000/api/v1/events”
var honeycomb = function(event_name, label, value) {
var honey_event = { 'event': { name: event_name, property_1: label, property_2: value, url: window.location.href }, unique_key: unique_key } var honey_request = new XMLHttpRequest(); honey_request.open("POST", endpoint, true); honey_request.setRequestHeader('Content-Type', 'application/json'); honey_request.onreadystatechange = function() { }; honey_request.send(JSON.stringify(honey_event));
}; honeycomb(“pageview”); </script> “‘ Make sure you replace “<insert unique key here>” with the one assigned to you when you [sign up](localhost:3000/users/sign_up)!
Also: Paste this snippet directly into an HTML element to track clicks (like in a link, in the example below): “‘ <a href=“#” onClick=“honeycomb(’click’, ‘video’, ‘play’);”>Play Video</a>
“‘ The first parameter (’Click’) refers to the event action or category, and the other two (‘Video’ and ‘Play’) are optional custom properties. Rename these to describe the context/thing being clicked, or whatever makes sense for you.