Javascript Library - Storyberg/Docs GitHub Wiki
Paste this code just after the opening <head> tag on every page of your application.
<script type="text/javascript">
var _sbq=_sbq||[];
var _sbk=_sbk||"YOUR_API_KEY"; // TODO Add your Storyberg API Key
function _sbs(e){setTimeout(function(){var t=document,n=t.getElementsByTagName("script")[0],r=t.createElement("script");r.type="text/javascript";r.async=true;r.src=("https:"==document.location.protocol?"https://":"http://")+e;n.parentNode.insertBefore(r,n)},1)}_sbs("https://s3.amazonaws.com/storyberg/js/analytics.js");
</script>
Add this code just after the opening <head> tag on every page where users are logged in (after the above code).
<script type="text/javascript">
_sbq.push(['identify', {
user_id: '1234', // TODO Output the current logged in users ID
email: '[email protected]', // TODO Output the current logged in users email address
sign_up_date: 1330779887, // TODO Output the current logged in sign up date as a Unix timestamp
name: 'Test User' // TODO Output the current logged in users name
}]);
</script>
To record when a user sees a new feature or experiment, execute the following call.
<script type="text/javascript">
_sbq.push(['identify', {
user_id: '1234', // TODO Output the current logged in users ID (required)
tag: 'EXPERIMENT TAG', // TODO Update with the experiment tag (optional)
}]);
</script>
To automatically record when a user sees a new feature or experiment, add the following data attribute to any HTML element.
<div data-sb-tag="EXPERIMENT TAG">
<!-- TODO Update data-sb-tag attribute with the experiment tag -->
</div>
To record when a user does an activity, execute one the following calls.
<script type="text/javascript">
_sbq.push(['event', {
name: 'key',
}]);
</script>
<script type="text/javascript">
_sbq.push(['event', {
name: 'paid',
}]);
</script>
<script type="text/javascript">
_sbq.push(['event', {
name: 'EVENT NAME', // TODO Update with an event name (no spaces)
}]);
</script>