Skip to content

JavaScript library for performing simple experiments with your site using Mothership

License

Notifications You must be signed in to change notification settings

MothershipApp/analytics

Repository files navigation

Mothership Analytics

Implementation

Download Library

Download mothership-analytics.lib.js and place it in your javascript directory (the example below we assume it's called "js").

Place the following code in your <head>:

<script>
  window.MothershipConfig = {
    apiKey: "XXXXXX"
  };
</script>
<script src="/js/mothership-analytics.lib.js"></script>

Implement your events:

API

window.MothershipAnalytics.newEvent(experienceKey, eventKey, pointValue = 1, force = false);

Example:

window.MothershipAnalytics.newEvent("experienceKey", "eventKey", 10);

Keep in mind that an experienceKey/eventKey combination will only fire one time per page load unless you pass the force flag. This is to prevent components that you may include multiple times on a page from skewing your results. However, if you do want to force a fire (like in a SPA application where the page only really loads one time) you can pass a fourth argument to make that happen.

window.MothershipAnalytics.newEvent("experienceKey", "eventKey", 10); // Will report
window.MothershipAnalytics.newEvent("experienceKey", "eventKey", 10); // Will not report because it's a duplicate of the first one
window.MothershipAnalytics.newEvent("experienceKey", "eventKey", 10, true); // Will report even though it's a duplicate

Development and Testing

Build

yarn build
npm run build

Development

yarn serve
npm run serve

Testing

yarn test
npm run test

About

JavaScript library for performing simple experiments with your site using Mothership

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published