Tracking and Consent Functions
Create Tracker
create (<integer> piAId, <integer> piCId, <string> tracker domain hostname)
Creates the Account Engagement tracker necessary for analytics. Add 1000 to the Account Engagement instance ID (piAId
) and the campaign ID (piCId
).
Example
Set Tracked Properties
set(<string> propertyName, value)
Return: undefined
Updates the value of a tracked property. Subsequent page views sent to Account Engagement include the updated property value. See Writeable Analytics Parameters for the properties that support updates.
Example
Send Page View
sendPageView()
Return: undefined
Sends a page view to Account Engagement that includes the current values of Tracker object properties. If the value of the pi_opt_in
cookie is false, then no request is made.
Example
Show Consent Banner
showConsentBanner()
Shows the Account Engagement consent banner, allowing the visitor to choose to give consent to Account Engagement analytics tracking.
Example
Hide Consent Banner
hideConsentBanner(<null|boolean > status)
Hide the Account Engagement consent banner from the page. If true
or false
is given, the pi_opt_in
status is updated. If null
is given, the banner is hidden and the status isn't updated.
Example
Set Opt In
setOptIn(<boolean> status)
Set the value of the pi_opt_in
cookie. Account Engagement analytics only records page views when the value of this cookie is true
.
Example
Revoke Consent
revokeConsent()
Return: undefined
Deletes any existing visitor tracking cookies and sets the pi_opt_in
cookie value to false
.
If the pi_opt_in
cookie is true or unset a page view request is sent to Account Engagement. If your Account Engagement settings require the visitor to give consent based on their geo, then no page view is recorded and the Account Engagement consent banner is displayed.
Example
Clear Tracking Cookies
clearTrackingCookies()
Deletes all Account Engagement tracking cookies.
Example
Adding analytics actions to the queue is the primary way to interact with Account Engagement analytics. To retrieve data from the Account Engagement analytics tracker, pass a callback function into the queue. The callback function is executed when the queue is processed and it is passed a reference to the Account Engagement tracker.
Since analytics is processed asynchronously, interacting with tracked values must be done within a callback function that is processed after the analytics library has loaded. In this example the current consent status is fetched, which then can be used to gate logic on your web page.
Get Property Value
get(<string> propertyName)
Return: mixed
Returns the value of a tracked property.
Example
Get Consent Status
getConsentStatus()
Return: null|boolean
Returns the current consent status for the Account Engagement tracker. If no consent status has been set, null
is returned.
Example
The following parameters can be updated using the set
function.
Name | Type | Description |
---|---|---|
url | String | The url of the tracked page. default: document.URL. |
title | String | The title of the tracked page. default: document.title. |
referrer | String | The referring location to the tracked page. default: document.referrer or query string param 'referrer' if it exists. |
piEmail | String | Manually link a visitor to a prospect by email address. Must be a valid email address. |
piPoints | Integer | Manually override score for page view. |
piProfileId | Integer | Manually set the profile for visitors. |
utmCampaign | String | Google Analytics parameter. Can be used to set Account Engagement campaign. |
utmMedium | String | Google analytics parameter. Distinguishes Bing/Yahoo natural vs. paid search. |
utmSource | String | Google analytics parameter. Can be used to set the prospect's source field. |
utmTerm | String | Google analytics parameter. Used with an ad id in the Google Ad Keyword report. |