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
Return value
kiflo('getTrackingCode') returns one of two values:
Example
When to use this method
Usekiflo('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.