Tracking and Consent Functions

Standard Functions

Create Tracker

create (<integer> piAId, <integer> piCId, <string> tracker domain hostname)

Creates the Pardot tracker necessary for analytics. Add 1000 to the Pardot account 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 Pardot 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 Pardot 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

showConsentBanner()

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

Example

hideConsentBanner(<null|boolean > status)

Hide the Pardot 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. Pardot analytics only records page views when the value of this cookie is true.

Example

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 Pardot. If your Pardot account settings require the visitor to give consent based on their geo, then no page view is recorded and the Pardot consent banner is displayed.

Example

Clear Tracking Cookies

clearTrackingCookies()

Deletes all Pardot tracking cookies.

Example

Interacting with Pardot Analytics

Adding analytics actions to the queue is the primary way to interact with Pardot analytics. To retrieve data from the Pardot 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 Pardot 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

getConsentStatus()

Return: null|boolean

Returns the current consent status for the Pardot tracker. If no consent status has been set, null is returned.

Example

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 Pardot 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.