To avoid race condition of our script loading and your application trying to communicate to it, you should add the following javascript code before any of the calls to the library.
window.CelloAttribution=window.CelloAttribution||function(t,...o){if("getReferral"===t)throw new Error("getReferral is not supported in this context. Use getUcc instead.");let e,n;const i=new Promise((t,o)=>{e=t,n=o});return window.CelloAttributionCmd=window.CelloAttributionCmd||[],window.CelloAttributionCmd.push({command:t,args:o,resolve:e,reject:n}),i}

attachTo(formElement)

Attaches hidden input to the passed HTMLFormElement node, or array of nodes.
window.CelloAttribution("attachTo", formElement);

Accepts

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

Example

window.CelloAttribution("attachTo", document.querySelector("form"));

getCampaignConfig()

Returns campaign config pertaining to a new user.
const campaignConfig = await window.CelloAttribution("getCampaignConfig");

Returns

campaignConfig
object
The campaign config object:

getReferrerName()

Returns the referrer’s name, if provided in the referral link.
const name = await window.CelloAttribution("getReferrerName");

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).
const ucc = await window.CelloAttribution("getUcc");

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.

getReferral()

⚠️ Deprecated: use getUcc() instead.