3rd Party Integrations
Product Journal Integrations

Any Website

Instructions for adding AppFit to your website

Getting Started Adding AppFit to any Website

First things first, you need to have access to your website code and permissions to edit the header code.

To forward your Segment data to AppFit, you will need to be an Admin or a Manager of a project.

Sign up for an AppFit account and create your Company

Be sure to choose the right Industry, Platform, and Focus. AppFit will recommend which metrics you should track based on your answers to these questions.

Select Integrations from the Menu

For now, you can get your API Key from going into either Amplitude or Segment integration and copying it there

In your website builder or code, add the following code to your header, replacing the Write Key with your API key

<script>
  window.AppFit = {
    cache: {},
    trackEvent(eventName, payload) {
      if (!window.AppFit.cache) {
        window.AppFit.cache = {}
      }
      if (!window.AppFit.cache.events) {
        window.AppFit.cache.events = [];
      }
      window.AppFit.cache.events.push({ eventName: eventName, payload: payload })

      return Promise.resolve();
    },
    identifyUser(userId) {
      if (!window.AppFit.cache) {
        window.AppFit.cache = {}
      }
      window.AppFit.cache.identity = userId;
    }
  };
  function startAppFit(apiKey) {
    window.AppFit.apiKey = apiKey;
    var script = document.createElement('script');
    script.type = 'module';
    script.src = 'https://d1433kipn7zjh1.cloudfront.net/appfit.js';
    var fallbackScript = document.createElement('script');
    fallbackScript.noModule = true;
    fallbackScript.src = 'https://d1433kipn7zjh1.cloudfront.net/appfit-legacy.js';
    var first = document.getElementsByTagName('script')[0];
    first.parentNode.insertBefore(script, first);
    first.parentNode.insertBefore(fallbackScript, first);
  }
  startAppFit('WRITE KEY');
</script>
<script>
    window.AppFit.trackEvent('screen_viewed', { screen: window.location.pathname })
</script>

Now you can map your website events to the metrics inside AppFit

Your metrics will begin to automatically update as soon as AppFit receives data.