Script Initialization and Timing
The attribution script loads asynchronously. To avoid race conditions between script loading and your application calls, you have two options:Option 1: Queue Function (Recommended)
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
Form(s) to attach the hidden input to
Example
getCampaignConfig()
Returns campaign configuration for new users, including discount information.
Returns
The campaign config object:
Complete Example
getReferrerName()
Returns the referrer’s name, if provided in the referral link.
Returns
Referrer’s name or
undefinedgetUcc()
Retrieves the referral code ucc from the URL or the cookie (if cookies are enabled).
Returns
Unique campaign code/referral code
attachAll()
attachAll()⚠️ Deprecated: forms are now auto-detected and the hiddenuccinput is injected automatically. UseattachTo(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
Testing Attribution Methods
Test all methods in your browser console:Network and Loading Issues
Common Integration Patterns
getReferral()
getReferral()
⚠️ Deprecated: use getUcc() instead.