Skip to main content

Script Initialization and Timing

The attribution script loads asynchronously. To avoid race conditions between script loading and your application calls, you have two options: Add this JavaScript code before any calls to the library to queue commands until the script loads:

Option 2: Wait for Script Initialization

Alternatively, wait for the script to load before making calls:

attachTo(formElement)

Attaches hidden input to the passed HTMLFormElement node, or array of nodes.

Accepts

formElement
HTMLFormElement | HTMLFormElement[]
required
Form(s) to attach the hidden input to

Example


getCampaignConfig()

Returns campaign configuration for new users, including discount information.

Returns

campaignConfig
object
The campaign config object:

Complete Example

getReferrerName()

Returns the referrer’s name, if provided in the referral link.

Returns

name
string | undefined
Referrer’s name or undefined

getUcc()

Retrieves the referral code ucc from the URL or the cookie (if cookies are enabled).

Returns

ucc
string
Unique campaign code/referral code

attachAll()

⚠️ Deprecated: forms are now auto-detected and the hidden ucc input is injected automatically. Use attachTo(formElement) for targeted cases instead.

Troubleshooting

Attribution Script Not Loading

Methods Returning undefined or null

Common causes:
  • Script not fully initialized - wait for DOM load or use the queue function
  • Incorrect method syntax - ensure you use window.CelloAttribution("methodName")
  • No referral data available - user didn’t come from a referral link
Solutions:

Testing Attribution Methods

Test all methods in your browser console:

Network and Loading Issues

Common Integration Patterns


getReferral()

⚠️ Deprecated: use getUcc() instead.