Tracking
Six methods cover everything. track and identify are the two you will actually use.
| Method | Answers |
|---|---|
track | What happened? |
identify | Who is this? |
page | Which page are they on? |
group | Which company do they belong to? |
alias | These two IDs are the same person |
reset | They logged out |
track
flowfyanalytics.track(eventName, properties)
flowfyanalytics.track("Product Viewed", {
product_id: "P-4471",
name: "Wireless Headphones",
price: 199.99,
currency: "SAR",
category: "Electronics"
});
The event name is matched against a fixed list. Order Completed becomes a purchase on Meta, TikTok and Snapchat; a name Flowfy does not recognise is still stored, but no advertising platform will do anything with it. Use the event reference.
Names are matched without regard to case, so order completed still counts as a purchase — but they are stored exactly as you send them, and Meta matches its own standard events case-sensitively. Send them as written in the reference.
Property names are snake_case. Sending productId instead of product_id will not raise an error; the property is simply never read.
identify
flowfyanalytics.identify(userId, traits)
flowfyanalytics.identify("customer_9931", {
email: "sara@example.com",
phone: "+966500000000",
first_name: "Sara",
last_name: "Al-Otaibi"
});
Call it when someone logs in, registers or updates their details — and on every page load where you already know who they are, since the SDK does not carry an identity across sessions on its own.
Until you call it, the shopper is tracked under a generated anonymous ID. identify links the events that came before it to the person, which is how someone who browsed on a phone and bought on a desktop is counted once instead of twice.
email and phone matter more than the rest: Meta, TikTok and Snapchat use them to match a conversion back to an ad view, and they are hashed before they leave Flowfy.
Common traits are email, phone, first_name, last_name, name, username, age, birthday, gender, avatar, title, created_at, and address as a nested object with street_address, city, state, postal_code and country. Anything else you add is kept as-is.
page
flowfyanalytics.page();
flowfyanalytics.page("Catalogue", "Headphones");
flowfyanalytics.page({ path: "/products/headphones", title: "Headphones" });
Call it once per page view. In a single-page app the URL changes without a reload, so call it yourself on every route change:
router.afterEach((to) => {
flowfyanalytics.page({ path: to.fullPath, title: document.title });
});
The URL, path, title, referrer and any UTM parameters are filled in for you.
group, alias, reset
flowfyanalytics.group("company_88", { name: "Alpha Trading", plan: "wholesale" });
flowfyanalytics.alias("customer_9931", "temp_44f0");
flowfyanalytics.reset();
group attaches a shopper to a company, which is useful for wholesale. alias merges two IDs belonging to the same person. reset clears the stored identity and issues a fresh anonymous ID — call it on logout, or the next shopper on a shared device inherits the previous one.
What the SDK collects for you
None of this needs to be sent. It is attached to every event automatically:
- Page — URL, path, title, referrer, referring domain, search string, and the first referrer of the session
- Campaign —
utm_source,utm_medium,utm_campaign,utm_term,utm_content - Screen — width, height, pixel density, inner width and height
- Locale and timezone
- User agent, and the IP address, which Flowfy resolves to a country
Click IDs from the ad platforms — fbclid, ttclid, sc_click_id and the cookies that follow them — are read from the URL too. They are what connects an order back to the ad that produced it, so do not strip those parameters when your router tidies up URLs.
Waiting for the SDK
Queued calls replay in order once the SDK loads, so you rarely need this. When you want to read something back:
flowfyanalytics.ready(function () {
console.log(flowfyanalytics.getAnonymousId());
});
getUserId(), getUserTraits(), getSessionId() and getGroupId() are available on the same object.
Consent
If you gate tracking behind a cookie banner, load the SDK with pre-consent enabled and call consent() once the shopper accepts:
flowfyanalytics.consent();
Until then events are held rather than sent. With no consent setup configured, the SDK tracks immediately.