Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Current »

Overview

Instructions to send "Add to Cart" clicks information using the Javascript Tagging Library.

Step-by-step guide

This event must be triggered when any product is added to cart from search result page or from product detail page after a search. At that moment, the function trackAdd2Cart  should be executed.

trackAdd2Cart

Use this function to send information when a user clicks on an "Add to Cart" button.

trackAdd2Cart(terms, page, position, productid, title, url, options, callback)

Parameters

ParameterDescriptionData TypeMandatory
termsThe query typed by the userStringYes
pageThe page numberIntegerYes
positionThe position in SERP of the product selected.IntegerNo*
productIdThe product ID of the selected result.StringNo*
titleThe product or result titleStringYes
urlDestination URL, for example product detail pageStringYes
optionsObject that may contain information about filters and other required dataObjectNo
callbackFunction that will be executed after sending dataFunctionNo
*This parameters are not mandatory for the service but necessary for the statistics

Options

The options object should contains additional parameters not passed as parameters in function call:

{    
	lang: LANGUAGUE,
	scope: SCOPE,
	store: STORE,
	catalog: CATALOG,
	section: SECTION,
	user: USER_ID,
	session: SESSION_ID
}
Parameter
Description
Data Type
Mandatory
langLanguage identifier (es, en...)StringNo
scopeScope identifier (desktop, mobile, android app, iOS app...)StringNo
storeStore value if it is required for the projectStringNo
catalogCatalog value if it is required for the projectStringNo
sectionSection value if it is required for the projectStringNo
userUserID used for user based servicesString*No
sessionSessionID used for user based servicesStringNo

*UserID should be an UUID identifier.

NOTE: The values for scope and lang will be provided by the Empathy Team.

NOTE: If you are setting up the trackAdd2Cart function into the product detail page, terms and page values will be relative to the product situation into the results grid before being clicked by the user.


The callback function will receive an object with the following contents. Also params sent in options will be included:

{
	q: terms,
	page: page,
	productId: productid,
	position: position,
	title: title,
    url: url,
    follow: false
}

NOTE: The callback also receives the parameter lang, user, session and the other params sent in options.

Code sample

empathyTAG.trackAdd2Cart('test', 1, 3, "My product id", 'My product title', 'http://MY_PRODUCT_URL.com',{lang:'en','scope:'testscope'},function(){});

  • No labels