Calls and functions available in the Fresh Relevance JavaScript API
setEmail
$TB.setEmail(emailAddress)
$TB.setEmail(emailAddress)
Parameter | Type | Description |
---|---|---|
emailAddress | string | The email address of the user |
Set the email address for this person, for example, when they've logged in.
You should call sendBeacon directly afterward, to ensure the data is sent to the Fresh Relevance server.
setMobile
$TB.setMobile(mobile, code)
$TB.setMobile(mobile, code)
Parameter | Type | Description |
---|---|---|
mobile | string | The mobile phone number of the user in either E.164 format or local format if you also pass a code value. |
code | string | The 2 character country code for the mobile number in ISO 3166-1 alpha-2 format |
Set the mobile number (and optional mobile code) for this person. You can pass the mobile number in either international format (E.164 format) or in local format with the country code the number is registered in so that Fresh Relevance can validate and convert to international format.
You should call sendBeacon directly afterward, to ensure the data is sent to the Fresh Relevance server.
setDetails
$TB.setDetails(emailAddress, firstName, lastName, fullName, options)
$TB.setDetails(emailAddress, firstName, lastName, fullName, options)
Parameter | Type | Description |
---|---|---|
emailAddress | string | The email address of the user |
firstName | string | The first name of the user |
lastName | string | The last name of the user |
fullName | string | The full name of the user |
options | object | Set options.emailType to one of:- e for plain email address- b64e for base64-encoded email address- rc4e for RC4 encrypted email address |
Set details for this person, for example, when they've logged in.
Any parameters passed as null
are ignored.
Note, you don't need to call sendBeacon separately, as this is called automatically as part of this call.
setData
$TB.setData(rootData, extraData)
$TB.setData(rootData, extraData)
Parameter | Type | Description |
---|---|---|
rootData | object | Specify any Person fields you want to set. |
extraData | object | Any other data that you want to be added to the person's record. |
Set data for this person.
Example
Setting a person details with extra gender information passed.
$TB.setData({'e': emailAddress, 'fn': firstName, 'ln': lastName}, {'gender': customerGender}
Note, you don't need to call sendBeacon separately, as this is called automatically as part of this call.
raiseSignal
$TB.raiseSignal(namespace, signal)
$TB.raiseSignal(namespace, signal)
Parameter | Type | Description |
---|---|---|
namespace | string | The namespace for the custom signal. Note: You might have multiple triggers within the same namespace - the first trigger that satisfies its filter criteria is run. |
extraData | object | Any data items that need passing to the custom trigger. |
Raise custom signals from your site so Fresh Relevance can respond to the specified triggers / actions of your customer on your site. For example, when a customer orders a brochure or viewed a particular page, you can pass data through to the signal, which is available all the way through to email send time, so it can be merged into an email.
Custom signals have a property namespace that allows multiple custom signals to exist, without interfering with each other.
$TB.raiseSignal('your_namespace', {'exampleitem': 'examplevalue', 'another': 'value'});
The extraData can be accessed in layouts using the prefix extra.
and then the field name you want to reference from within the extraData object. e.g.
Example Item: {{ extra.exampleitem }}
Another: {{ extra.another }}
sendBeacon
$TB.sendBeacon()
$TB.sendBeacon()
Syncs all pending data to the Fresh Relevance server. We recommend calling this after and significant data point changes to ensure it is synced, unless you have used a call that does this automatically for you.