Page tracking
Tracks user behavior as they move through pages on your site.
Template
The following Javascript code template must be placed all pages, except the order confirmation page.
Configuration
version
Type:
integer
Scope: All pages
Required
Tracking format version identifier used by the Fanplayr platform. Must be set to 3
.
accountKey
Type:
string
Scope: All pages
Required
Unique string used identify your account with the Fanplayr platform.
storeDomain
Type:
string
Scope: All pages
Default: Value of
window.location.hostname
Can be used to optionally override the domain that Fanplayr associates with the session.
connect
Type:
object
Scope: All pages
Default:
undefined
applyToCartUrl
Type:
string
Scope: All pages
Default:
undefined
sessionOfferUrl
Type:
string
Scope: All pages
Default:
undefined
allowOfferPrompt
Type:
boolean | function
Scope: All pages
Default:
undefined
Offer Flyout widgets can be configured to prompt users to apply any collected offers to the cart by forcing open the wallet when no offer has been applied. By default, this feature is only triggered on the cart page.
This option used to enabled or disable this feature for the current page (regardless of page type). If a function is provided, the return value is used.
Possible Values
true
- Allows offer prompts on current page, including non-cart pages.false
- Disables offer prompts on current page.
Regardless of the value, the offer prompt feature will only be used if there is no offer currently applied to the cart.
userConsentMode
Type:
boolean
Scope: All pages
Default:
undefined
Determines whether Fanplayr is required to consider the user's consent in order to store their data.
Please see User Consent for Datafor details.
userConsentStatus
Type:
boolean
Scope: All pages
Default:
undefined
If userConsentMode
is set to true
then this will define wether the user has consented to have their data stored.
Please see User Consent for Datafor details.
Tracking variables
The following variables must be provided in the data
object. Example:
lineItemCount
Type:
integer
Scope: All pages
Required
The number of unique products currently added to the cart.
numItems
Type:
integer
Scope: All pages
Required
The total quantity of all items added to the cart.
gross
Type:
float
Scope: All pages
Required
The total value (in the specified currency) of the items currently in cart. More specifically, the sum total of the items in the cart before discounts, shipping and taxes.
total
Type:
float
Scope: All pages
Required
This is the total value (in the specified currency) of the items currently in cart. More specifically, the sum total of the items in the cart before shipping and taxes, but after discounts.
discount
Type:
float
Scope: All pages
Required
This is the total value of discounts applied to the cart. This means discounts such as free shipping or shipping discounts should not change this value.
discountCode
Type:
string
Scope: All pages
Required
The discount code applied to the cart (if any). If there are multiple discount codes applied, separated them with commas.
pageType
Type:
string
Scope: All pages
Required
The type of the current page. Valid values are:
home
– The homepage.prod
– A product page.cat
– A category page or list of products.srch
– A specific search page, or search results page.cart
– The shopping cart page.checkout
- A page in the checkout flow, but not the order confirmation page.blog
- A blog page.page
– Any other page. E.g. 'About', 'Contact' etc.
currency
Type:
string
Scope: All pages
Default:
"USD"
brands
Type:
string[]
Scope: Home, Product and Category pages
An array of brand names associated with the current page.
categories
Type:
string[]
Scope: Product and Category pages
Required
An array of category names associated with the current page.
categoryId
Type:
string
Scope: Product and Category pages
ID of the current category. This should be specified on category and product pages.
categoryName
Type:
string
Scope: Product and Category pages
Name of the current category if available.
productId
Type:
string
Scope: Product pages
Required
A single, unique product identifier. Used to differentiate products in the cart or order.
productSku
Type:
string
Scope: Product pages
Required
productPrice
Type:
float
Scope: Product pages
Required
The unit price of the product visible to the user.
For carts that implement a base price and a discounted/sale price, use the discounted price if it is the price shown to users when they add the product to the cart.
productName
Type:
string
Scope: Product pages
Required
The name of the product currently being browsed. E.g. "Red Shoes".
productUrl
Type:
string
Scope: Product pages
Required
URL of the page that displays full details of the product. This property should be used when tracking a product "quickview" so that the actual URL of the product page is captured correctly.
productImage
Type:
string
Scope: Product pages
Required
URL of the product image.
customerEmail
Type:
string
Scope: All pages
The email address of the current user.
customerId
Type:
string
Scope: All pages
Deprecated
This is an identifier of the user that is internal to your site. This is used to track new and repeat users.
products
Scope: All pages
Default:
[]
An array of objects (or JSON) representing the products that are currently in the shopping cart.
cartAction
Scope: All pages
Default:
"override"
This is a special variable that determines how Fanplayr will treat cart-related data for the current tracking call. It can be used to carry forward cart details (total value in cart, products in cart etc) from the previous page view if they are unavailable for the current tracking call.
identities
Scope: All pages
searchQuery
Type:
string
Scope: Search pages
Custom Data
If required, Fanplayr is able to capture custom data while tracking user behavior on your site. This data can be used for segmenting on data not already supported natively by Fanplayr.
An example of use would be passing in the “logged in” status of a user, internal segmentation information or which is the current store (for example using Magento Enterprise).
To use this feature please contact Fanplayr so we can help you set it up.
Example
The following example could be used to track:
A user who is currently browsing the "Red Shoes" product page
With two items already added to their cart:
Two cups worth $10 each
One t-shirt worth $45
A coupon code, "WINTER5", applying a $5 discount to the cart
Dynamic Sites
When the above tracking code is implemented correctly, Fanplayr will track pages after they load as a user browses through the website. This is sufficient for most sites, but additional steps may be needed for sites that load content dynamically.
For example, sites that load product details in a popup overlay instead of redirecting the user to a new page, you will need to implement an additional step in order to correctly track product views.
Additional page views can be tracked dynamically after the initial page view has been tracked by Fanplayr by passing the tracking data to the fanplayr.reinitialize() method.
The tracking data follows the same format as detailed above. Keep in mind that all of the required properties must be present.
Last updated
Was this helpful?