Skip to main content
When a visitor arrives on your website through a partner referral link, Kiflo stores a unique tracking code in a first-party browser cookie (kfl_key). The kiflo('getTrackingCode') method lets you read that value from JavaScript at any time, so you can use it in your own code — most commonly to pass it to your backend when you need to create customers or leads via the Kiflo REST API rather than the JS SDK.

Syntax

This call is synchronous — it returns the value immediately without any callbacks or promises.

Return value

kiflo('getTrackingCode') returns one of two values:

Example

When to use this method

Use kiflo('getTrackingCode') when you create customers or leads from your backend code instead of calling kiflo('customer', ...) or kiflo('lead', ...) in the browser. The browser-based SDK methods automatically bundle the tracking code with the customer data. But if your sign-up logic runs on the server, the backend has no access to the visitor’s browser cookie. The solution is to:
1

Read the tracking code in the browser

Call kiflo('getTrackingCode') in the browser, for example inside your form’s submit handler.
2

Send the tracking code to your server

Include the tracking code in your form data or API request payload. A common pattern is to store it in a hidden form field:
Or include it directly in a JSON request:
3

Create the customer via the Kiflo REST API

From your backend, call the Kiflo REST API to create the customer and pass the trackingCode in the request body. Kiflo uses this value to attribute the customer to the correct partner.See the Kiflo API reference for the full request schema.
The Kiflo JS SDK must be installed on the page for kiflo('getTrackingCode') to work. Make sure the snippet in your <head> has fully loaded before you call this method. If you need to react to the exact moment the snippet is ready, use the ready event instead.