Difference between revisions of "ATC/Current/SDK/Web tracking API"

From Genesys Documentation
Jump to: navigation, search
m (Text replacement - "\|Platform=([^\|]*)GenesysEngage-onpremises([\|]*)" to "|Platform=$1GenesysEngage-cloud$2")
(Published)
Line 2: Line 2:
 
|Standalone=No
 
|Standalone=No
 
|DisplayName=Web Tracking API
 
|DisplayName=Web Tracking API
|Platform=GenesysEngage-cloud, PureConnect, GenesysCloud
 
 
|TocName=Web Tracking API
 
|TocName=Web Tracking API
 +
|Context=Learn how to track user activity via an API.
 
|ComingSoon=No
 
|ComingSoon=No
|Context=Learn how to track user activity via an API.
+
|Platform=PureConnect, GenesysCloud, GenesysEngage-cloud
 
|Section={{Section
 
|Section={{Section
 
|sectionHeading=About the Web Tracking API
 
|sectionHeading=About the Web Tracking API
|Standalone=No
 
|ComingSoon=No
 
 
|alignment=Vertical
 
|alignment=Vertical
 
|structuredtext=The Web Tracking API lets you track what visitors do on your website. Tracking data is collected through a series of interactions occurring on your website such as pageviews, button clicks, and custom events. These interactions are grouped into visits and act as a container for the actions taken on your website by a specific visitor.
 
|structuredtext=The Web Tracking API lets you track what visitors do on your website. Tracking data is collected through a series of interactions occurring on your website such as pageviews, button clicks, and custom events. These interactions are grouped into visits and act as a container for the actions taken on your website by a specific visitor.
  
 
Visits do not have a predefined duration. Depending on your visitor, the visit may be a few seconds or a couple of hours long. A new visit will be created when the visitor has been idle for 30 minutes or more, but they all will be linked to the same visitor.
 
Visits do not have a predefined duration. Depending on your visitor, the visit may be a few seconds or a couple of hours long. A new visit will be created when the visitor has been idle for 30 minutes or more, but they all will be linked to the same visitor.
|fullwidth=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
 
|sectionHeading=Obtain consent before tracking visitors
 
|sectionHeading=Obtain consent before tracking visitors
 
|anchor=ObtainConsent
 
|anchor=ObtainConsent
|Standalone=No
 
|ComingSoon=No
 
 
|alignment=Vertical
 
|alignment=Vertical
|structuredtext={{NoteFormat|To be compliant with GDPR requirements, consider if you need to obtain a visitor's consent before tracking their data. For more information on using Altocloud in a GDPR-compliant manner, see {{#mintydocs_link:topic=GDPR|manual=AdminGuide|version=Current|link text=GDPR.}}|1}}
+
|structuredtext={{NoteFormat|To be compliant with GDPR requirements, consider if you need to obtain a visitor's consent before tracking their data. For more information on using {{MintyDocsProduct}} in a GDPR-compliant manner, see {{#mintydocs_link:topic=GDPR|manual=AdminGuide|version=Current|link text=GDPR.}}|1}}
  
  
Line 40: Line 35:
  
 
You are responsible for setting the value for the <tt>`consentGiven`</tt> variable based on the visitor's choice.
 
You are responsible for setting the value for the <tt>`consentGiven`</tt> variable based on the visitor's choice.
|fullwidth=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
 
|sectionHeading=Enable web tracking
 
|sectionHeading=Enable web tracking
|Standalone=No
 
|ComingSoon=No
 
 
|alignment=Vertical
 
|alignment=Vertical
 
|structuredtext=To enable Web tracking on your website, initialize the Tracking SDK and then call the <tt>pageview</tt> method when a visitor navigates to a new page.
 
|structuredtext=To enable Web tracking on your website, initialize the Tracking SDK and then call the <tt>pageview</tt> method when a visitor navigates to a new page.
|fullwidth=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
 
|sectionHeading=Stop tracking if a visitor revokes consent
 
|sectionHeading=Stop tracking if a visitor revokes consent
 
|anchor=StopTracking
 
|anchor=StopTracking
|Standalone=No
 
|ComingSoon=No
 
 
|alignment=Vertical
 
|alignment=Vertical
 
|structuredtext=If a visitor revokes consent at any point, invoke the <tt>destroy</tt> command to stop tracking and remove all cookies, as shown in the following example.<br />
 
|structuredtext=If a visitor revokes consent at any point, invoke the <tt>destroy</tt> command to stop tracking and remove all cookies, as shown in the following example.<br />
 
<source lang="javascript">
 
<source lang="javascript">
// to disable tracking and delete Altocloud cookies
+
// to disable tracking and delete Genesys Predictive Engagement cookies
 
ac('destroy');
 
ac('destroy');
 
</source>
 
</source>
|fullwidth=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
 
|sectionHeading=Types of tracked data
 
|sectionHeading=Types of tracked data
 
|anchor=CollectionMethods
 
|anchor=CollectionMethods
|Standalone=No
 
|ComingSoon=No
 
 
|alignment=Vertical
 
|alignment=Vertical
 
|structuredtext=The Journey JavaScript SDK lets you customize how you collect tracking data for your website. The most basic form of tracking is page view tracking. For page view tracking, {{MINTYDOCSPRODUCT}} records each page a visitor visits. You can also use the Journey JavaScript SDK to record custom visitor activities such as button clicks. For more information see ''Track custom events'', below.
 
|structuredtext=The Journey JavaScript SDK lets you customize how you collect tracking data for your website. The most basic form of tracking is page view tracking. For page view tracking, {{MINTYDOCSPRODUCT}} records each page a visitor visits. You can also use the Journey JavaScript SDK to record custom visitor activities such as button clicks. For more information see ''Track custom events'', below.
|fullwidth=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
 
|sectionHeading=Track pages viewed by your customers
 
|sectionHeading=Track pages viewed by your customers
|Standalone=No
 
|ComingSoon=No
 
 
|alignment=Vertical
 
|alignment=Vertical
 
|structuredtext=The <tt>pageview</tt> method tracks the pages viewed by your visitors. To send a <tt>pageview</tt>, call the <tt>ac</tt> function and pass <tt>pageview</tt> as the first argument.  
 
|structuredtext=The <tt>pageview</tt> method tracks the pages viewed by your visitors. To send a <tt>pageview</tt>, call the <tt>ac</tt> function and pass <tt>pageview</tt> as the first argument.  
Line 81: Line 64:
 
ac('pageview');
 
ac('pageview');
 
</source>{{NoteFormat|By default, the {{MINTYDOCSPRODUCT}} tracking snippet contains the <tt>ac</tt> function.|1}}
 
</source>{{NoteFormat|By default, the {{MINTYDOCSPRODUCT}} tracking snippet contains the <tt>ac</tt> function.|1}}
|fullwidth=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
 
|sectionHeading=Track custom events
 
|sectionHeading=Track custom events
 
|anchor=record
 
|anchor=record
|Standalone=No
 
|ComingSoon=No
 
 
|alignment=Vertical
 
|alignment=Vertical
 
|structuredtext=The <tt>record</tt> method allows you to track custom events, usually as a result of a person interacting with an element or control in your website, for example, the click of a button.  
 
|structuredtext=The <tt>record</tt> method allows you to track custom events, usually as a result of a person interacting with an element or control in your website, for example, the click of a button.  
 
The <tt>record</tt> method takes two parameters:
 
The <tt>record</tt> method takes two parameters:
* The name of the event to record as a string. '''Note:''' See ''Guidelines for custom event names'' below.
+
 
* An (optional) key-value hash of properties for the event.
+
*The name of the event to record as a string. '''Note:''' See ''Guidelines for custom event names'' below.
* An (optional) callback function that will be invoked when the request is completed.
+
*An (optional) key-value hash of properties for the event.
* An (optional) callback timeout, in milliseconds, to configure how long to wait if the event is taking too long to complete. This is useful to capture events (such as file downloads) before navigating to a different page/URL, making sure the visitor is always redirected.
+
*An (optional) callback function that will be invoked when the request is completed.
 +
*An (optional) callback timeout, in milliseconds, to configure how long to wait if the event is taking too long to complete. This is useful to capture events (such as file downloads) before navigating to a different page/URL, making sure the visitor is always redirected.
  
 
<source lang="javascript">  
 
<source lang="javascript">  
Line 117: Line 98:
 
}, 400);
 
}, 400);
 
</source>
 
</source>
|fullwidth=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
 
|sectionHeading=Guidelines for custom event names
 
|sectionHeading=Guidelines for custom event names
|Standalone=No
 
|ComingSoon=No
 
 
|alignment=Vertical
 
|alignment=Vertical
 
|structuredtext={{NoteFormat|Event names must be a maximum of 255 characters. You can use any combination of lowercase alphanumeric characters and an underscore. Keep event names short and descriptive. |1}}
 
|structuredtext={{NoteFormat|Event names must be a maximum of 255 characters. You can use any combination of lowercase alphanumeric characters and an underscore. Keep event names short and descriptive. |1}}
Line 128: Line 106:
  
 
Examples of custom event names include:
 
Examples of custom event names include:
* <tt>"detected_errors"</tt>
+
 
* <tt>"section_failed"</tt>
+
*<tt>"detected_errors"</tt>
* <tt>"section_submitted"</tt>
+
*<tt>"section_failed"</tt>
* <tt>"product_added"</tt>
+
*<tt>"section_submitted"</tt>
* <tt>"product_removed"</tt>
+
*<tt>"product_added"</tt>
* <tt>"address_selected"</tt>
+
*<tt>"product_removed"</tt>
|fullwidth=No
+
*<tt>"address_selected"</tt>
 
|Status=No
 
|Status=No
 
}}
 
}}
 
}}
 
}}

Revision as of 13:33, November 4, 2020

This topic is part of the manual Journey JavaScript SDK for version Current of Genesys Predictive Engagement.

Learn how to track user activity via an API.

About the Web Tracking API

The Web Tracking API lets you track what visitors do on your website. Tracking data is collected through a series of interactions occurring on your website such as pageviews, button clicks, and custom events. These interactions are grouped into visits and act as a container for the actions taken on your website by a specific visitor.

Visits do not have a predefined duration. Depending on your visitor, the visit may be a few seconds or a couple of hours long. A new visit will be created when the visitor has been idle for 30 minutes or more, but they all will be linked to the same visitor.

Obtain consent before tracking visitors

Important
To be compliant with GDPR requirements, consider if you need to obtain a visitor's consent before tracking their data. For more information on using Genesys Predictive Engagement in a GDPR-compliant manner, see GDPR.


To implement tracking after receiving consent, modify the tracking snippet so that the `ac('init')` and `ac('pageview')` are only called if consent is given, as shown in the following example:

 (function(a,t,c,l,o,u,d){a['_genesysJourneySdk']=o;a[o]=a[o]||function(){
  (a[o].q=a[o].q||[]).push(arguments)},a[o].l=1*new Date();u=t.createElement(c),
  d=t.getElementsByTagName(c)[0];u.async=1;u.src=l;u.charset='utf-8';d.parentNode.insertBefore(u,d)
  })(window, document, 'script', 'https://apps.inindca.com/journey/sdk/js/web/v1/ac.js', 'ac');
if (consentGiven) {
// Call the ac('init') function to enable tracking  
  ac('init', 'a061a3fe-7a80-4b50-9d3b-df88c0f9efad', { region: 'use1' });
  ac('pageview');
}

You are responsible for setting the value for the `consentGiven` variable based on the visitor's choice.

Enable web tracking

To enable Web tracking on your website, initialize the Tracking SDK and then call the pageview method when a visitor navigates to a new page.

Stop tracking if a visitor revokes consent

If a visitor revokes consent at any point, invoke the destroy command to stop tracking and remove all cookies, as shown in the following example.

// to disable tracking and delete Genesys Predictive Engagement cookies
ac('destroy');

Types of tracked data

The Journey JavaScript SDK lets you customize how you collect tracking data for your website. The most basic form of tracking is page view tracking. For page view tracking, Genesys Predictive Engagement records each page a visitor visits. You can also use the Journey JavaScript SDK to record custom visitor activities such as button clicks. For more information see Track custom events, below.

Track pages viewed by your customers

The pageview method tracks the pages viewed by your visitors. To send a pageview, call the ac function and pass pageview as the first argument.

ac('pageview');
Important
By default, the Genesys Predictive Engagement tracking snippet contains the ac function.

Track custom events

The record method allows you to track custom events, usually as a result of a person interacting with an element or control in your website, for example, the click of a button. The record method takes two parameters:

  • The name of the event to record as a string. Note: See Guidelines for custom event names below.
  • An (optional) key-value hash of properties for the event.
  • An (optional) callback function that will be invoked when the request is completed.
  • An (optional) callback timeout, in milliseconds, to configure how long to wait if the event is taking too long to complete. This is useful to capture events (such as file downloads) before navigating to a different page/URL, making sure the visitor is always redirected.
 
ac('record', 'section_opened');

You may also provide extra metadata with your custom event:

 
ac('record', 'button_clicked', {
  companyName: 'Acme Inc,',
  employees: '100-500'
});

The following code sample shows how to record a file downloaded and navigate to the file URL /files/pricing.pdf when the event is captured, or after 400 milliseconds:

 
ac('record', 'file.downloaded', {
  name: 'Pricing',
  fileType: 'pdf'
}, function () {
  navigateTo('/files/pricing.pdf');
}, 400);

Guidelines for custom event names

Important
Event names must be a maximum of 255 characters. You can use any combination of lowercase alphanumeric characters and an underscore. Keep event names short and descriptive.

The suggested format for custom event names is: object-delimiter-action, where object is the object that was interacted with, and action is the type of interaction that occurred.

Examples of custom event names include:

  • "detected_errors"
  • "section_failed"
  • "section_submitted"
  • "product_added"
  • "product_removed"
  • "address_selected"
Retrieved from "https://all.docs.genesys.com/ATC/Current/SDK/Web_tracking_API (2024-07-27 23:25:21)"
Comments or questions about this documentation? Contact us for support!