Skip to content

Integrate Insights

To track the impact of your content, you need to integrate the axite script into your website or shop and use it to send back events to the axite platform.

Prerequisites

Before you can send impact events for your content, you need to have completed setting up your pipeline and have published content. As part of the content that axite delivers to your system you'll also receive a contentId that you need to use to associate the events with the content.

Setup

Add this javascript snippet to your web page and initialize it with your pipeline id and the content id of the content that's on that page.

html
<script>
  window.axite = window.axite || new Proxy({q: []}, { get: (t, p) => t[p] ? t[p] : (...a) => t.q.push([p, ...a]) });
  (function() {
    var script = document.createElement('script');
    script.src = 'https://impact.axite.app/axite.v1.js';
    script.async = true;
    document.head.appendChild(script)
  })();
  axite.init({
    pipeline: 'yourOrg/yourPipeline',
    contentId: '1234',
    trackUniqueViews: true
  });
  axite.logEvent('view');
</script>

Sending back events

To send an event, call axite.logEvent(eventType, options):

ParameterDescription
eventType (string)One of 'view', 'conversion', 'return'
options (object; optional)Key contentId: provide or override content id on a per-call basis

logEvent() is designed to survive page navigation, so calling it as onclick handler of a link or submit button works fine.

Tracking Unique Visitors/Views

Axite impact tracking does neither store (client or server side) nor send any data that can be used to identify individual users by default. However, you can enable tracking of unique views by setting trackUniqueViews: true in the axite.init() call. This will store visited content ids client side only and send back only the timestamp of the previous view to the server when the view event is sent. No user ids or other personal data is sent or stored on our servers. If you explicitly set trackUniqueViews: false, all existing data that is saved client side will be deleted.

Updating Config on the Fly

If you want to change the config after calling init, for example to enable trackUniqueViews after the user has approved tracking, you can call axite.init() again with the new config. The new config will be merged with the existing one.

js
axite.init({
  trackUniqueViews: true
});

Complete example

html
<!DOCTYPE html>
<html><head>
  <script>
    window.axite = window.axite || new Proxy({q: []}, { get: (t, p) => p == 'q' ? t.q : (...a) => t.q.push([p, ...a]) });
    (function() {
      var script = document.createElement('script');
      script.src = 'https://impact.axite.app/axite.v1.js';
      script.async = true;
      document.head.appendChild(script)
    })();
    axite.init({
      pipeline: 'yourOrg/yourPipeline',
      contentId: '1234',
      trackUniqueViews: true
    });
    axite.logEvent('view');
  </script>
</head><body>
  <form>
    <button onclick="axite.logEvent('conversion')">Add To Basket</button>
  </form>
</body></html>

More to Come

Are you bundling your frontend and already use packages from npm? Let us know and we'll provide you with an axite npm package to simplify script loading!