Dotdigital Tag API methods
The following API methods are client-side functions which send user interaction data to a server.
Using the Dotdigital Tag, you can capture events such as page views, user logins, product browsing and cart updates, and access this data in both Dotdigital and Fresh Relevance accounts.
- Purpose: These methods facilitate real-time data ingestion, supporting personalized marketing and analytics by mapping data to defined schemas.
- Usage: They are called in JavaScript to track user actions and send data to a server endpoint.
Learn more about the Dotdigital Tag.
Key events
Event type | Method | Description |
---|---|---|
Page change | window.ddg.track(data) | Tracks page visits. |
User identification | window.ddg.identify({...}) | Identifies a user with specific attributes such as email, mobile number, and name. |
Product browse | window.ddg.productBrowse( {...} ) | Tracks product browsing events with detailed product information. |
Product list | window.ddg.productList({data}) | Tracks a list of products viewed by the contact. |
Cart update | window.ddg.cartUpdate({...}) | Updates cart information with detailed cart and product data. |
Checkout | window.ddg.checkout({...}) | Tracks checkout events. When used, the cart Insight data’s CartPhase in Dotdigital is set to ORDER_CHECKOUT . |
Purchase complete | window.ddg.purchaseComplete({...}) | Tracks purchase completion events. When used, the cart Insight data’s CartPhase in Dotdigital is set to ORDER_COMPLETE . |
Custom signal | window.ddg.signal("SignalName",{...}) | Sends custom event signals.* |
*Custom signals in Dotdigital are only available in our CXDP account package.
Method reference
ddg.track()
Example:
window.ddg.track();
ddg.identify()
Parameters:
email (required): User's email address. // At least one identifier (email or mobile) is required
mobileNumber (required unless email is defined): User's mobile number
firstName: User's first name. //only made available in Fresh Relevance
lastName: User's last name. //only made available in Fresh Relevance
fullName: User's full name. //only made available in Fresh Relevance
Example:
window.ddg.identify({
email: "[email protected]",
mobileNumber: "+447911123456",
firstName: "Jane",
lastName: "Doe",
fullName: "Jane Doe"
});
ddg.productBrowse(product)
Parameters:
productId (required): Unique identifier for the product.
sku (required): Stock Keeping Unit.
name (required): Name of the product.
url (required): URL of the product page.
imageUrl (required): URL of the product image.
imageThumbnailUrl (optional): URL of the product thumbnail image.
price (required): Price of the product.
salePrice (optional): Sale price of the product.
currency (required): Currency code (ISO 4217).
priceInclTax (optional): Price including tax.
salePriceInclTax (optional): Sale price including tax.
status (optional): Status of the product.
stock (optional): Stock of the product
description (optional): Description of the product.
categories (optional): Array of category the product belongs to.
extraData (optional): Additional data related to the product.
lang (optional): Language code.
brand (optional): Brand of the product.
variantId (optional): Unique identifier of the variant
variants (optional): Array of product variants
variants (object)
Property name | Data type |
---|---|
id | string |
url | string |
name | string |
stock | number |
image | string |
category (object)
A product category can be either a string
or { categoryName: string; groupName: string; }
Property name | Data type |
---|---|
categoryName | string |
groupName | string |
Example:
window.ddg.productBrowse({
productId: 'uniqueproductid',
name: 'name',
price: 1.12,
imageThumbnailUrl: 'http://www.image.com/thumbnail.jpg',
imageUrl: 'http://www.image.com/image.jpg',
priceInclTax: 1.35,
salePrice: 3.2,
salePriceInclTax: 3.5,
sku: 'sku-123',
status: 'status',
stock: 1,
url: 'http://product.com/product.html',
brand: 'brand name',
lang: 'language',
categories: [
'category 1',
{ categoryName: 'category 3', groupName: 'category group' }],
currency: 'currency',
description: 'description',
extraData: {
'string value': 'hello world',
'int value': 1542,
'float value': 1.12,
'boolean value': true
},
variantId: 'var1',
variants: [
{
id: 'var1',
image: 'http://www.image.com/image_a.jpg',
name: 'variation 1',
stock: 1,
url: 'http://product.com/product_variation1.html'
},
{
id: 'var2',
image: 'http://www.image.com/image_b.jpg',
name: 'variation 2',
stock: 1,
url: 'http://product.com/product_variation2.html'
}
]
});
ddg.productList(products)
Parameters:
products: Array of product objects.
Example:
window.ddg.productList(
[
{
brand: 'brand name',
categories: [
'category 1',
{ categoryName: 'category 3', groupName: 'category group' }],
currency: 'currency',
description: 'description',
extraData: {
'string value': 'hello world',
'int value': 1542,
'float value': 1.12,
'boolean value': true
},
imageThumbnailUrl: 'http://www.image.com/thumbnail.jpg',
imageUrl: 'http://www.image.com/image.jpg',
lang: 'language',
name: 'product 1',
price: 1.12,
priceInclTax: 1.35,
productId: 'product id',
salePrice: 3.2,
salePriceInclTax: 3.5,
sku: 'sku-123',
status: 'status',
stock: 1,
url: 'http://product.com/product.html',
variantId: 'var1',
variants: [
{
id: 'var1',
image: 'http://www.image.com/image_a.jpg',
name: 'variation 1',
stock: 1,
url: 'http://product.com/product_variation1.html'
},
{
id: 'var2',
image: 'http://www.image.com/image_b.jpg',
name: 'variation 2',
stock: 1,
url: 'http://product.com/product_variation2.html'
}
]
},
{
brand: 'brand name',
categories: [
'category 1',
{ categoryName: 'category 3', groupName: 'category group' }],
currency: 'currency',
description: 'description',
extraData: {
'string value': 'hello world',
'int value': 1542,
'float value': 1.12,
'boolean value': true
},
imageThumbnailUrl: 'http://www.image.com/thumbnail.jpg',
imageUrl: 'http://www.image.com/image.jpg',
lang: 'language',
name: 'product 2',
price: 1.12,
priceInclTax: 1.35,
productId: 'product id 2',
salePrice: 3.2,
salePriceInclTax: 3.5,
sku: 'sku-123',
status: 'status',
stock: 1,
url: 'http://product.com/product.html',
variantId: 'var1',
variants: [
{
id: 'var1',
image: 'http://www.image.com/image_a.jpg',
name: 'variation 1',
stock: 1,
url: 'http://product.com/product_variation1.html'
},
{
id: 'var2',
image: 'http://www.image.com/image_b.jpg',
name: 'variation 2',
stock: 1,
url: 'http://product.com/product_variation2.html'
}
]
}
]
);
ddg.cartUpdate()
Cart attributes:
Property name | Data type | Required | Description |
---|---|---|---|
cartId | string | Yes | Unique identifier for the cart |
currency | string | Yes | Currency code ISO 4217 |
subtotal | number | Yes | Subtotal amount |
shipping | number | No | Shipping cost |
discountAmount | number | No | Discount amount |
taxAmount | number | No | Tax amount |
grandTotal | number | Yes | Grand total amount |
cartUrl | string | Yes | URL of the cart page |
products | object[ ] | Yes | Array of cart product objects |
Cart products:
Property name | Data type | Required |
---|---|---|
sku | string | Yes |
name | string | Yes |
description | string | No |
categories | CartProductCategory[ ] Array of categories | No |
extraData | Object | No |
unitPrice | number | Yes |
unitPriceInclTax | number | No |
salePrice | number | No |
salePriceInclTax | number | No |
quantity | number | Yes |
totalPrice | number | No |
totalPriceInclTax | number | No |
imageUrl | string | Yes |
productUrl | string | Yes |
variantId | string | No |
brand | string | No |
productId | string | Yes* |
*Only required for Fresh Relevance
Example:
window.ddg.cartUpdate({
cartId: "123ABCZZFSEFSEFESZZZZZee",
currency: "USD",
subtotal: 35.98,
shipping: 8,
discountAmount: 0,
taxAmount: 0,
grandTotal: 35.98,
cartUrl: "https://www.example.com/checkout/cart",
products: [
{
sku: "576879",
name: "Shirt",
description: "A super great description of the product",
category: "Shirts >> T-Shirts >> Blue",
other: {"fieldName": "This can be a string or any value you like"},
unitPrice: 11.99,
salePrice: 11.99,
quantity: 20,
totalPrice: 23.98,
imageUrl: "http://www.example.com/a/p/shirt.jpeg",
productUrl: "http://www.example.com/index.php/shirt.html"
}
]
});
ddg.checkout()
When this method is used, the cartinsight's CartPhase in Dotdigital is set to
ORDER_CHECKOUT
.
Parameters:
cartId (required): Unique identifier for the cart.
currency (required): Currency code (ISO 4217).
subtotal (required): Subtotal amount.
shipping (optional): Shipping cost.
discountAmount (optional): Discount amount.
taxAmount (optional): Tax amount.
grandTotal (required): Grand total amount.
cartUrl (required): URL of the cart page.
products (required): Array of product objects in the cart.
Example:
window.ddg.checkout({
cartId: "123ABCZZFSEFSEFESZZZZZee",
currency: "USD",
subtotal: 35.98,
shipping: 0,
discountAmount: 0,
taxAmount: 0,
grandTotal: 35.98,
cartUrl: "https://www.example.com/checkout/cart",
products: [
{
sku: "576879",
name: "Shirt",
description: "A super great description of the product",
category: "Shirts >> T-Shirts >> Blue",
other: {"fieldName": "This can be a string or any value you like"},
unitPrice: 11.99,
salePrice: 11.99,
quantity: 20,
totalPrice: 23.98,
imageUrl: "http://www.my-website.com/a/p/shirt.jpeg",
productUrl: "http://www.my-website.com/index.php/shirt.html"
}
]
});
ddg.purchaseComplete()
This method can be used to generate order Insight records in Dotdigital if you aren’t otherwise syncing orders into Dotdigital.
Learn more in Add the Dotdigital Tag to your website: Advanced settings.
Parameters:
cartId (required): Unique identifier for the cart.
orderId (required): Unique identifier for the order.
currency (required): Currency code (ISO 4217).
subtotal (required): Subtotal amount.
shipping (optional): Shipping cost.
discountAmount (optional): Discount amount.
taxAmount (optional): Tax amount.
grandTotal (required): Grand total amount.
cartUrl (required): URL of the cart page.
products (required): Array of product objects in the cart.
Example:
window.ddg.purchaseComplete({
cartId: "123ABCZZFSEFSEFESZZZZZee",
orderId: "45645",
currency: "USD",
subtotal: 35.98,
shipping: 0,
discountAmount: 0,
taxAmount: 0,
grandTotal: 35.98,
cartUrl: "https://www.my-website.com/checkout/cart",
products: [
{
sku: "576879",
name: "Shirt",
description: "A super great description of the product",
category: "Shirts >> T-Shirts >> Blue",
other: {"fieldName": "This can be a string or any value you like"},
unitPrice: 11.99,
salePrice: 11.99,
quantity: 20,
totalPrice: 23.98,
imageUrl: "http://www.my-website.com/a/p/shirt.jpeg",
productUrl: "http://www.my-website.com/index.php/shirt.html"
}
]
});
ddg.signal()
ddg.signal(signalName, attributes)
Parameters:
signalName: Name of the signal. (Required)
attributes: Object containing signal attributes.
Example:
window.ddg.signal("Search destination", {
"query":"Bali",
"travel_from_date" : "2025-07-03"
});
Result:
Insight collection: Search_destination
Insight collection type: signal
Record
id: 5dbe0b01-c0d0-423e-a457-5c9d49d6e5b6
signal: Search destination
created_date: 2025-05-13T14:07:30.64Z
attributes:
query: Bali
travel_from_date: 2025-07-03
Updated 1 day ago