Tracking and Consent Functions

The Tracking and Consent API supports these functions.

Standard 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

1pdt(create', 0001, 0002, ‘go.example.com’);

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

1pdt("set", "title", "About Us");

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

1pdt("sendPageView");

Consent Functions 

Show Consent Banner 

showConsentBanner()

Shows the Account Engagement consent banner, allowing the visitor to choose to give consent to Account Engagement analytics tracking.

Example

1pdt("showConsentBanner");

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

1// hide the consent banner
2pdt("hideConsentBanner", null);
3// hide the banner and set opt in status to false
4pdt("hideConsentBanner", false);
5// hide the banner and set opt in status to true
6pdt("hideConsentBanner", true);

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

1pdt("setOptIn", true);

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

1pdt("revokeConsent");

Clear Tracking Cookies 

clearTrackingCookies()

Deletes all Account Engagement tracking cookies.

Example

1pdt("clearTrackingCookies");

Interacting with Account Engagement Analytics 

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.

1pdt(function (tracker) {
2  let consentStatus = tracker.getConsentStatus();
3  if (consentStatus === false) {
4    // take custom site action
5  }
6});

Get Property Value 

get(<string> propertyName)

Return: mixed

Returns the value of a tracked property.

Example

1pdt(function (tracker) {
2  let url = tracker.get("url");
3});

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

1pdt(function (tracker) {
2  let status = tracker.getConsentStatus();
3});

Writeable Analytics Parameters 

The following parameters can be updated using the set function.

NameTypeDescription
urlStringThe url of the tracked page. default: document.URL.
titleStringThe title of the tracked page. default: document.title.
referrerStringThe referring location to the tracked page. default: document.referrer or query string param ‘referrer’ if it exists.
piEmailStringManually link a visitor to a prospect by email address. Must be a valid email address.
piPointsIntegerManually override score for page view.
piProfileIdIntegerManually set the profile for visitors.
utmCampaignStringGoogle Analytics parameter. Can be used to set Account Engagement campaign.
utmMediumStringGoogle analytics parameter. Distinguishes Bing/Yahoo natural vs. paid search.
utmSourceStringGoogle analytics parameter. Can be used to set the prospect’s source field.
utmTermStringGoogle analytics parameter. Used with an ad id in the Google Ad Keyword report.