Developer documentation
This article gives a guide to help you understand what data to track for some common use cases. To see the full technical documentation outlining all the data you can send through the Fresh Relevance SDK and Dotdigital Tag, go to our Developer Hub documentation.
First-time visitor browses products, doesn’t add to cart
A first-time visitor to your site browses products but doesn’t add them to their cart.
Following their session, you might want to send the visitor an abandoned browse campaign.
Data to track
1. Track home page and category page views and any other pages the shopper visits
Call the relevant page-specific tracking call, or window.ddg.track(), for the pages the user has visited.
Learn more in the section Track page views.
Required attributes:
Attribute | Examples |
url | |
title | “Homepage” or “Men’s clothing” |
pageType | “1” (Homepage) or “3” (product_list) |
For product pages, call window.ddg.productBrowse()
Required attributes:
Attribute | Description or example |
productId | Unique string ID for the product, for example, “686-foundation-jacket” |
sku | “686f-jacket” |
name | “686 Foundation jacket” |
url | |
imageUrl | |
price | 69.97 |
currency | Currency code, for example, “USD” |
categories | Array/string, for example, ["Men's Clothing", "Jackets", "Foundation"] |
If variants are selectable without page reload, fire another productBrowse with updated variantId and variants (array of variant objects).
2. Identify the visitor if they enter contact information
Call: window.ddg.identify()
Required:
email or
mobileNumber
If captured firstName, lastName or fullName can all be passed as well.
Identifying the visitor is required to trigger an abandoned browse send. However, even without identifying the visitor, any session data is stored against an anonymous record in Fresh. This data will still be usable to personalize future website visits.
You can also include optional product fields, for example salePrice, description, brand.
Any additional data you want to track outside of our defined schema can be tracked as extraData.
Don’t send cart updates unless a product is actually added to the cart.
Visitor receives abandoned browse/cart email, returns to site and adds to cart
A visitor receives your abandoned browse campaign from Dotdigital and either clicks through or returns on their own to view your site. They then add a product to their cart but still don’t check out.
You can send them an abandoned cart campaign to encourage them to complete their purchase.
Data to track
1. Visitor identification
Visitors are automatically identified on email click through. If our cookies are still in place, the visitor can also be tied back to their record in Fresh Relevance.
To ensure that we attribute browsing sessions as often as possible, you should call the identify method to provide contact details for the visitor whenever you have them.
Call: window.ddg.identify()
Required:
email or
mobileNumber
2. Track the product detail view
Call: window.ddg.productBrowse()
Attribute | Description or example |
productId | Unique string ID for the product, for example, “686-foundation-jacket” |
sku | “686f-jacket” |
name | “686 Foundation jacket” |
url | |
imageUrl | |
price | 69.97 |
currency | Currency code, for example, “USD” |
categories | Array/string, for example, ["Men's Clothing", "Jackets", "Foundation"] |
If variant selected:
variantId
variants
3. Track cart updates when an item is added
Call: window.ddg.cartUpdate()
Required attributes:
Attribute | Description or example |
cartId | Unique string for the cart, this should be the same throughout the shopping/browsing session |
currency | Currency code in ISO 4217 format. Example, USD |
subtotal | Subtotal cart price before taxes, shipping, discounts, etc. |
grandtotal | Grand total of cart including taxes, shipping, discounts, etc. |
cartUrl | |
products | Array of cart product objects, this includes the following for each product:
|
Recommended attributes:
cartPhase (for example, "ORDER_PENDING")
This is automatically tracked by the Dotdigital Tag if not specified.
You can also include optional cart or product fields such as shipping or discountAmount.
You must update cart info every time cart contents change.
You can track additional custom attributes with
extraData.No
purchaseCompleteevent is recorded unless checkout is finalized.
Visitor receives abandoned cart campaign and completes their purchase
The visitor returns to your site after receiving an abandoned cart campaign and completes their purchase.
Data to track
Visitors are automatically identified on email click through, but, wherever possible, you should send the visitor's identifying information.
1. Visitor identification
Call: window.ddg.identify()
Required:
email or
mobileNumber
2. Track cart view
Call: window.ddg.cart() for cart views, window.ddg.cartupdate for changes to a cart
Required attributes:
cartId, currency, products (each with productId, sku, name)
You can also include optional cart/product fields such as subtotal, discountAmount.
3. Track start of checkout
Call: window.ddg.checkout()
Required attributes:
"ORDER_CHECKOUT" cart phase is set automatically.
Attribute | Description or example |
cartId | Unique string for the cart. If the cart is the same, then this should match the cartId used for previous cartUpdate calls. |
currency | Currency code in ISO 4217 format. Example, USD |
subtotal | Subtotal cart price before taxes, shipping, discounts, etc. |
grandtotal | Grand total of cart including taxes, shipping, discounts, etc. |
cartUrl | |
products | Array of cart product objects, this includes the following for each product:
|
4. Track completed purchase
Call: window.ddg.purchaseComplete()
Required attributes:
"ORDER_COMPLETE" cart phase is set automatically.
Attribute | Description or example |
cartId | Unique string for the cart. If the cart is the same, then this should match the cartId used for previous ddg.cartUpdate and ddg.checkout calls |
orderId | Unique string for the order. |
currency | Currency code in ISO 4217 format. Example, USD |
subtotal | Subtotal cart price before taxes, shipping, discounts, etc. |
grandtotal | Grand total of cart including taxes, shipping, discounts, etc. |
cartUrl | |
products | Array of cart product objects, this includes the following for each product:
|
optcan be used to provide product-level extra data, such as customisations or inscriptions.You can track additional custom attributes relating to a cart, like a coupon code, through the use of
extraData.You must only call
purchaseCompleteafter order payment/confirmation.You must use the same
cartIdthroughout a user session.
