JavaScript API Endpoints

Introduction

This article describes the API endpoints of the Rejoiner Javascript Library. You can review an overview of the basics in the Integration Guide here.

Quick Outline

Tracking Page and Product Views

trackPageView

By default, page views are tracked when the library loads. This endpoint can be used to disable this behavior.

_rejoiner.push(['trackPageView', false]);

addPageView

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)

Example:

_rejoiner.push(['addPageView', {'url': 'http://example.com?query=string'}]);

trackProductView

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 fields of the product.
**Important Note The  expiration_date field is stored as a proper date-time and is simply used for audience segmenting and display purposes.

Tracking Cart Items and Cart Data

setCartData

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 fields in the cart.

setCartItem

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.

removeCartItem

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

clearCartData

This endpoint will remove  all cart data from the current transaction. This is useful in a few situations:

  1. A customer removes an item, but the structure of the site does not allow calling of 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.
  2. A customer removes everything from their cart and you do not want this customer to be treated as abandoning a cart, but would rather have them be treated as abandoning a browse session.

This endpoint does not require any params.

EXAMPLE:

_rejoiner.push(['clearCartData']);

Tracking Conversions

sendConversion

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

Storing Customer Data

setCustomerData

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.

setCustomerEmail

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

subscribeToList

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.

customerOptIn

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.

EXAMPLE:

_rejoiner.push(['customerOptIn', {
  'email': 'test@example.com',
  'type': 'accepts marketing checkbox',
  'otherInfo': 'accepted marketing on checkout page'
}]);

Additional Data

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.

setSessionMetadata

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.

EXAMPLE:

_rejoiner.push(['setSessionMetadata', {
  'is_vip': 'yes',
}]);

setSessionDate

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

EXAMPLE:

_rejoiner.push(['setSessionDate', {
  'payment_date': new Date().toISOString(),
  'delivery_date': '2019-01-01T12:32:04.012Z'
}]);

Form Filtering

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:

  1. If setIncludeOnlyFormID was called and the field is not part of the forms specified, it is ignored, otherwise, continues to the next check.
  2. If setIncludeOnlyFieldID was called and the field's ID was not specified, it is ignored, otherwise, continues to the next check.
  3. If setIncludeOnlyFieldName was called and the field's name was not specified, it is ignored, otherwise, continues to the next check.
  4. If setExcludeFieldId was called and the field's ID was specified, it is ignored, otherwise, continues to the next check.
  5. If setExcludeFieldName was called and the field's name was specified, it is ignored, otherwise, continues to the next check.
  6. If the field is a password input, it is always ignored.
  7. The field has passed all checks and is scanned for email addresses.

Still need help? Contact Us Contact Us