Install the SDK

Add the Flowfy tracking script to a custom storefront and point it at your source.

The SDK is a script you add once to every page. It gives you a flowfyanalytics object that queues calls made before the script finishes downloading, so you can start tracking on the same page that loads it.

Salla stores get this automatically through the Flowfy app. Install it by hand only for a custom storefront.

Before you start

You need a write key. Open your source in Flowfy and copy it from the source's page. Everything below refers to it as YOUR_WRITE_KEY.

Add the script

Put this in <head>, before anything that tracks.

<script>
  (function () {
    var key = "flowfyanalytics";
    var analytics = (window[key] = window[key] || []);

    if (analytics.snippetExecuted) return;
    analytics.snippetExecuted = true;

    var methods = [
      "setDefaultInstanceKey", "load", "ready", "page", "track", "identify",
      "alias", "group", "reset", "setAnonymousId", "startSession",
      "endSession", "consent", "addCustomIntegration"
    ];

    methods.forEach(function (method) {
      analytics[method] = function () {
        analytics.push([method].concat(Array.prototype.slice.call(arguments)));
      };
    });

    var script = document.createElement("script");
    script.src = "https://cdn.flofy.co/v3/modern/iife/flowfy.min.js";
    script.async = true;
    document.head.appendChild(script);

    analytics.load("YOUR_WRITE_KEY", "https://edge.flofy.co");
    analytics.page();
  })();
</script>

That is the whole install. The loop is what lets flowfyanalytics.track(...) work before the real SDK has arrived — calls are pushed onto an array and replayed once it loads.

What the arguments mean

flowfyanalytics.load(writeKey, dataPlaneUrl, options)
ArgumentValue
writeKeyYour source's write key
dataPlaneUrlhttps://edge.flofy.co
optionsOptional — see

Check that it works

Load a page and open the browser console:

flowfyanalytics.getAnonymousId()

A string means the SDK loaded. Then open the Network tab, filter on edge.flofy.co, and trigger an event — you should see a POST to /v1/page or /v1/track answered with 204.

If both look right, open Live events on the source's page in Flowfy. Events appear there within a few seconds.

Batching

By default the SDK sends each event as its own request. On a busy storefront you can batch them:

flowfyanalytics.load("YOUR_WRITE_KEY", "https://edge.flofy.co", {
  plugins: ["XhrQueue"],
  queueOptions: {
    batch: {
      enabled: true,
      maxItems: 50,
      maxSize: 512 * 1024,
      flushInterval: 60000
    }
  }
});

flushInterval is in milliseconds and maxSize in bytes. Batched events wait in the browser until one of the three limits is reached, so a shopper who closes the tab early loses whatever is still queued. Leave batching off unless request volume is an actual problem.

Identifying a logged-in shopper

If you already know who the shopper is when the page renders, say so on load:

flowfyanalytics.identify("customer_9931", {
  name: "Sara Al-Otaibi",
  email: "sara@example.com",
  phone: "+966500000000"
});

The rest of the methods are on the tracking page.

If nothing arrives

No flowfyanalytics in the console. The script did not load. Look for flowfy.min.js in the Network tab — a blocked request usually means an ad blocker, or a Content-Security-Policy that does not allow cdn.flofy.co.

Requests answered with 400. The write key is missing or malformed. Re-copy it from the source page.

Requests answered with 204, but nothing in Live events. The request was well-formed but the write key does not match a source. A 204 confirms receipt only — it is not a check that the key is valid.

Events fire twice. The snippet is on the page more than once. snippetExecuted guards against that, so a duplicate usually means two different copies of the snippet, or a router re-running it on navigation.

npm

There is no published npm package yet. Use the script tag above.