This article describes the API endpoints of the Rejoiner Javascript Library. You can review an overview of the basics in the Integration Guide here.
By default, a page view is tracked on each page where the library loads. This endpoint can be used to disable this behavior.
_rejoiner.push(['trackPageView', false]);
This endpoint can be used to manually track page views.
Param Name | Required | Type | Notes |
---|---|---|---|
url |
Yes | String | Full URL of the page to track (including query string) |
_rejoiner.push(['addPageView', {'url': 'http://example.com?query=string'}]);
This endpoint is used to track product views. It also updates Rejoiner's information about a product on your site.
Param Name | Required | Type | Notes |
---|---|---|---|
product_id |
Yes | String | A unique identifier of the product (e.g. a SKU) |
name |
No | String | The name of the product |
category |
No | Array of Strings | An array of categories the product belongs to |
price |
No | Integer | The price of a product in cents |
image_url |
No | String | The URL of an image or thumbnail of the product |
product_url |
No | String | The URL of the product page on your site |
stock |
No | Integer | The current stock value of the product |
expiration_date |
No | Date String | A string representing the date on which the product expires** |
Any additional params will be treated as strings and added to the
metadata
field of the product.
**Important Note
The expiration_date
field is stored as a proper datetime and is simply used for audience segmenting and display purposes.
This endpoint is used to add or update data about the current transaction as a whole.
Param Name | Required | Type | Notes |
---|---|---|---|
cart_value |
No | Integer | The total value of the cart in cents |
cart_item_count |
No | Integer | The total number of items in the cart |
promo |
No | String | Promo code applied to the cart |
return_url |
No | String | A unique url to return to the cart page |
order_number |
No | String | External ID for the order |
Any additional params will be treated as strings and added to the
metadata
field of the cart.
This endpoint is used to add or update data about an item added to cart in the current transaction.
Param Name | Required | Type | Notes |
---|---|---|---|
product_id |
Yes | String | The unique SKU or ID which identifies the product |
name |
No | String | The name of the product |
price |
No | Integer | The unit price of the product in cents |
description |
No | String | A short description of the product |
category |
No | Array of Strings | Categories which the product belongs to |
item_qty |
No | Integer | The quantity of the product in the cart |
qty_price |
No | Integer | The total price of the product (price X quantity) in cents |
product_url |
No | String | The URL of the product on your site |
image_url |
No | String | The URL of an image or thumbnail of the product |
expiration_date |
No | Date String | A string representing the date on which the product expires. |
NOTE: The
expiration_date
field is stored as a proper datetime and is simply used for audience segmenting and display purposes.Any additional params will be treated as strings and added to the
metadata
field of the cart item.
This endpoint removes an item from the cart in the current transaction based on the product_id
.
NOTE: You should call
setCartData
with updated parameters after removing a cart item to ensure accuracy.
Param Name | Required | Type | Notes |
---|---|---|---|
product_id |
Yes | String | The unique SKU or ID which identifies the product to be removed |
This endpoint will remove all cart data from the current transaction. This is useful in a few situations:
removeCartItem
. This
would lead to a situation where the removed item still exists in Rejoiner's database. If the entirety of the current
cart's data is available (this is usually the case), you can call clearCartData
to remove everything and then
make the corresponding setCartData
and setCartItem
calls to add it back.This endpoint does not require any params.
_rejoiner.push(['clearCartData']);
This endpoint will record a conversion with Rejoiner. Optional parameters may be specified to provide the cart data and cart items associated with the converted order. Although these parameters are optional, it is highly recommended that you provide them if possible. This will help ensure that the data Rejoiner has is accurate.
Param Name | Required | Type | Notes |
---|---|---|---|
cart_data |
No | CartData |
Same structure as setCartData params above |
cart_items |
No | Array of CartItem |
Same structure as setCartItem params above |
This endpoint stores information about the demographics of a customer.
Param Name | Required | Type | Notes |
---|---|---|---|
age |
No | Integer | Age of the customer |
birthdate |
No | String | Format must be YYYY-MM-DD |
gender |
No | String | 'm' of 'f' for Male or Female respectively |
language |
No | String | Language code of the customer |
name |
No | String | The name of the customer. This is split on the first space for first name and last name. |
This endpoint stores the email address of a customer.
Param Name | Required | Type | Notes |
---|---|---|---|
email |
Yes | String | The email address to attach to the current session |
This endpoint will subscribe an email address to the given email list in Rejoiner. The List ID can be found on the page for the desired list.
NOTE: This will also identify the current session with the given email address.
Param Name | Required | Type | Notes |
---|---|---|---|
email |
Yes | String | Email address to add to the list and attach to the current session |
list_id |
Yes | String | The ID of the list to add the customer to |
first_name |
No | String | The first name of the customer |
Any additional fields will be treated as strings and stored in the
custom_fields
of the list contact.
_rejoiner.push(['subscribeToList', {
'email': 'name@example.com',
'list_id': 'foobar',
'first_name': 'Name',
}]);
This endpoint will record explicit consent received by the customer. This information can then be used for reporting purposes to track when explicit consent was received and to ensure that emails are only sent to customers that have provided explicit consent.
Param Name | Required | Type | Notes |
---|---|---|---|
email |
Yes | String | Email address of the customer to record explicit consent |
Any additional fields will be treated as strings and stored along with the record of explicit consent. This will allow you to store any additional information you find necessary regarding how the consent was received.
_rejoiner.push(['customerOptIn', {
'email': 'test@example.com',
'type': 'accepts marketing checkbox',
'otherInfo': 'accepted marketing on checkout page'
}]);
The setCartData
and setCartItem
endpoints allow passing additional customer
parameters which are stored on the respective object's metadata
field. These endpoints allow for storing
additional custom data which relates to the customer's session rather than a cart or cart item.
This endpoint accepts custom parameters which are then stored on the metadata
field of the session. This can then
be used for filters and to define audiences in the application, or rendered into an email.
_rejoiner.push(['setSessionMetadata', {
'is_vip': 'yes',
}]);
This endpoint can be used to store specific dates about the session that are not necessarily part of the Rejoiner lifecycle. Dates should be given in UTC formatted as an ISO string. The available date fields are:
Param Name | Required | Type | Notes |
---|---|---|---|
payment_date |
No | Date String | In UTC |
fulfillment_date |
No | Date String | In UTC |
delivery_date |
No | Date String | In UTC |
_rejoiner.push(['setSessionDate', {
'payment_date': new Date().toISOString(),
'delivery_date': '2019-01-01T12:32:04.012Z'
}]);
By default, Rejoiner will scan all text inputs for email addresses and name information. If you want to exclude forms and/or specific fields, or if you want to only scan specific forms and/or fields, you can use the endpoints below. For example, if there is HTML markup like below:
<form id="form1">
<input type="text" id="fieldId1" name="fieldName1" />
<input type="text" id="fieldId2" name="fieldName2" />
<input type="password" id="fieldId3" name="fieldName3" />
</form>
<form id="form2">
<input type="text" id="fieldId4" name="fieldName4" />
<input type="text" id="fieldId5" name="fieldName5" />
<input type="password" id="fieldId6" name="fieldName6" />
</form>
By default, all of the text
inputs will be scanned.
All of the following endpoints that an array of strings as parameters, indicating the form IDs, field IDs, or field names to include or exclude.
// Exclude Fields by ID
_rejoiner.push(['setExcludeFieldID', ['fieldId1']]);
// Exclude Fields by Name
_rejoiner.push(['setExcludeFieldName', ['fieldName1', 'fieldName2']]);
// Only Scan Specific Fields by ID
_rejoiner.push(['setIncludeOnlyFieldID', ['fieldID4']]);
// Only Scan Specific Fields by Name
_rejoiner.push(['setIncludeOnlyFieldName', ['fieldName4']]);
// Only Scan Specific Forms by ID
_rejoiner.push(['setIncludeOnlyFormID', ['form2']]);
These can be combined to provide flexibility in determining the fields to scan. The order of priority is as follows:
setIncludeOnlyFormID
was called and the field is not part of the forms specified, it is ignored, otherwise, continues to the next check.setIncludeOnlyFieldID
was called and the field's ID was not specified, it is ignored, otherwise, continues to the next check.setIncludeOnlyFieldName
was called and the field's name was not specified, it is ignored, otherwise, continues to the next check.setExcludeFieldId
was called and the field's ID was specified, it is ignored, otherwise, continues to the next check.setExcludeFieldName
was called and the field's name was specified, it is ignored, otherwise, continues to the next check.