Emarsys Web Extend
The emarsys server side web extend provider makes use of the Web Extend Command.
Concept
Using Tag Manger, it's not really possible to send only one go
call, so what we do instead,
is sending multiple calls, ensuring to provide the same sessionId
, visitorId
& pageViewId
.
So instead of doing e.g. this:
// The usual commands to identify visitors and report cart contents.
ScarabQueue.push(['cart', [
{item: 'item_1', price: 19.9, quantity: 1},
{item: 'item_2', price: 29.7, quantity: 3}
]]);
// Passing on item ID to report product view. Item ID should match the value listed in the Product Catalog
ScarabQueue.push(['view', 'item_3']);
// Firing the ScarabQueue. Should be the last call on the page, called only once.
ScarabQueue.push(['go']);
We are doing this on the server side:
// The usual commands to identify visitors and report cart contents.
ScarabQueue.push(['cart', [
{item: 'item_1', price: 19.9, quantity: 1},
{item: 'item_2', price: 29.7, quantity: 3}
]]);
// Firing the ScarabQueue. Should be the last call on the page, called only once.
ScarabQueue.push(['go']);
// Passing on item ID to report product view. Item ID should match the value listed in the Product Catalog
ScarabQueue.push(['view', 'item_3']);
// Firing the ScarabQueue. Should be the last call on the page, called only once.
ScarabQueue.push(['go']);
Initialization
Since we need to trigger multiple commands, we need to ensure we're always sending the same sessionId
, visitorId
& pageViewId
for all calls.
The initialization sets the emarsys.page_view_id
variable into the dataLayer
to be sent with each following request.
sequenceDiagram
participant Data Layer
participant Web Container
participant Server Container
participant Emarsys
Web Container->>+Server Container: initialization (/gtag/js/emarsys)
Server Container->>Emarsys: pageViewId (sesssionId, visitorId)
Server Container->>-Web Container: Cookies (emarsys_cdv, emarsys_s)
Web Container->>Data Layer: emarsys.page_view_id
Commands
Cart
NOTE: The default page_view
event does not contain the items
so we need to enrich them in the collect
service.
sequenceDiagram
participant Web Container
participant Collect
participant Server Container
participant Emarsys
Web Container->>Collect: page_view
Collect->>+Server Container: enrich: items
Server Container->>Emarsys: cart<br/>Cookies (s, cdv, xp, fc)
Server Container->>-Web Container: Cookies (s, cdv, xp, fc)
Standard implementation
// The usual commands to identify visitors and report cart contents.
ScarabQueue.push(['cart', [
{item: 'item_1', price: 19.9, quantity: 1},
{item: 'item_2', price: 29.7, quantity: 3}
]]);
// Firing the ScarabQueue. Should be the last call on the page, called only once.
ScarabQueue.push(['go']);
View
sequenceDiagram
participant Web Container
participant Server Container
participant Emarsys
Web Container->>+Server Container: view_item
Server Container->>Emarsys: view<br/>Cookies (s, cdv, xp, fc)
Server Container->>-Web Container: Cookies (s, cdv, xp, fc)
Standard implementation
// Passing on item ID to report product view. Item ID should match the value listed in the Product Catalog
ScarabQueue.push(['view', 'item_3']);
// Firing the ScarabQueue. Should be the last call on the page, called only once.
ScarabQueue.push(['go']);
Category
sequenceDiagram
participant Web Container
participant Server Container
participant Emarsys
Web Container->>+Server Container: view_item_list
Server Container->>Emarsys: category<br/>Cookies (s, cdv, xp, fc)
Server Container->>-Web Container: Cookies (s, cdv, xp, fc)
Standard implementation
// Passing on the category path being visited. Must match the 'category' values listed in the Product Catalog
ScarabQueue.push(['category', 'Bikes > Road Bikes']);
// Firing the ScarabQueue. Should be the last call on the page, called only once.
ScarabQueue.push(['go']);
Purchase
sequenceDiagram
participant Web Container
participant Server Container
participant Emarsys
Web Container->>+Server Container: purchase
Server Container->>Emarsys: category<br/>Cookies (s, cdv, xp, fc)
Server Container->>-Web Container: Cookies (s, cdv, xp, fc)
Standard implementation
// Passing on order details. The price values passed on here serve as the basis of our revenue and revenue contribution reports.
ScarabQueue.push(['purchase', {
orderId: '231213',
items: [
{item: 'item_1', price: 19.9, quantity: 1},
{item: 'item_2', price: 29.7, quantity: 3}
]
}]);
// Firing the ScarabQueue. Should be the last call on the page, called only once.
ScarabQueue.push(['go']);
References