# Metakeen.js

## What is this project?

This project is meant to be a simple to use Javascript library that we include on all Keen IO web projects to track pageviews with a consistent approach and data model. It's meant to be dropped into Keen-Statics, Keen-Web and all other upcoming web projects to track pageviews without requiring any advanced configuration. Core things to know about this library:

* It tracks `pageviews` events automatically on any page it's loaded on.
* It requests the currently logged in user's data (if available) from Keen-Web.
* It stores the `firstInternalReferrer`, `firstExternalReferrer`, and other referrer properties in a cookie to be sent along with each `pageview` event.
* It sends along all the user, organization, project and page data is has available to it with each event that is tracked through it, so you only need to add the specific custom properties you want tracked.

## What's under the hood?
* Makes use of the `keen-tracking.js` library to handle tracking pageviews, setting up cookies, etc.

## How to use it

Include the script from the CDN:

```
<!-- Metakeen.js -->
<script src="https://d26b395fwzu5fz.cloudfront.net/metakeen-1.2.1.min.js"></script>
<script>
  $(document).ready(function(){
    window.metakeenClient = new window.Metakeen({
      enabled: true,
      debug: true,
      projectId: PROJECT_ID,
      writeKey: PROJECT_WRITE_KEY
    });
  });
</script>
```

## Contributing to this project:

1. Create the PR, including the build files created with `npm run build`.
2. Get a +1.
3. Merge into `master`.
4. Create a new PR with a new release of metakeen, essentially just a version bump in `package.json`.
5. Merge that PR.
6. Run the `deploy` npm task to get the new version on to our CDN.
7. Update `keen-statics`, `keen-web` and any other project that uses this library to the latest version.