Set up activities
Activities represent actions that your contacts perform. For example, the system logs activities when visitors view pages or submit forms. The gathered activity log allows you to evaluate the behavior of contacts and visitors across your content channels.
Activity logging requirements
Activity logging for contacts in Xperience is enabled by default.
Due to personal data protection policies, most activities are only logged for visitors who give consent to be tracked as contacts and have the required cookie level set (Visitor or All).
Some activities are logged automatically without any setup. However, certain activities require additional adjustments of your application.
Activity logging based on legitimate interest
The system logs Form submission and Member registration activities even for visitors who have not given tracking consent.
Data added into the system as a result of such activities only includes information explicitly entered into the related form (or member registration form).
For example, when an untracked visitor submits a form, the system creates a new contact with data based on the form’s mapping of fields to contact attributes. If the form contains an email address field and the submitted email matches an existing contact, the data is instead added or updated for the given contact. This type of activity logging does not enable any other type of tracking for the visitor.
Additionally, the system does not include sensitive context-specific information when logging such activities (for example URLs, channel identifiers, etc.).
Important
You need to ensure that usage of personal data collected through such activities falls under legitimate interest purposes, based on your project’s legal requirements. For example, you may be able to legally use the data to send form autoresponder emails. However, using the data to send unsolicited marketing messages may be a breach of data protection regulations.
Activity type overview
Xperience by Kentico tracks the following activities:
Activity type | Code name | Description |
Click | click | The visitor performed a click on a website. Logged via headless tracking API or cross-site tracking. |
Data input | datainput | The visitor entered data through a specific input. For example, such activities can be logged in headless tracking scenarios when a visitor submits information through a form in an external mobile app. Logged via headless tracking API or cross-site tracking. |
Email click | emailclick | The recipient of an email clicked a link within the content. Logging requirements Email statistic tracking must be enabled and set up for your application. To ensure compliance with data protection regulations, email activity logging is not active by default. Developers need to implement logic that decides when it is possible to track email activities for specific contacts, for example based on consents. See Log email activities for detailed information. |
Form submission | bizformsubmit | The visitor submitted a form. Logged automatically. |
Landing page | landingpage | The visitor opened a page when first viewing a website channel. Logging requirements To log Landing page activities, you need to enable the activity tracking feature for your application. The Landing page activity logging is affected by the CMSLandingPageLoaded cookie, which expires after 20 minutes. The expiration period of the key is renewed every time the website channel is accessed again. |
Member registration | memberregistration | The visitor registers as a member. Logged when the member becomes active (enabled), for example after confirming the registration when using double opt-in via email confirmation. Logged automatically. |
Page visit | pagevisit | The visitor viewed a web page. The page can be presented by an Xperience website channel, a site using the headless tracking API, or a site covered by cross-site tracking. Logging requirements To log Landing page and Page visit activities, you need to enable the activity tracking feature for your application. |
Custom activity types
In addition to the default activity types, you can define your own custom types. Logging of custom activities always needs to be ensure by the project’s developers, according to the intended purpose of the activities.
See Custom activities for more information.
Enable the activity tracking feature
To log the Landing page and Page visit activities, you need to explicitly enable the activity tracking feature for your application. The feature registers routes that receive and process activity logging requests.
Open your project in Visual Studio.
Edit the Program.cs file.
Enable activity tracking by calling the
UseActivityTracking
method of theIFeaturesBuilder
delegate. Pass the delegate as an argument toAddKentico
.C#using Kentico.Activities.Web.Mvc; using Kentico.Web.Mvc; ... WebApplicationBuilder builder = WebApplication.CreateBuilder(args); ... builder.Services.AddKentico(features => { features.UseActivityTracking(); });
To log page visits for website channels, register the activity logging script onto all pages by calling the
ActivityLoggingScriptV2
extension method in views.Call the method in your website’s main layout (and any other used layouts) to ensure that performed activities are logged for every page.
The logging script runs asynchronously, so we recommend adding it at the end of the <head> tag in the page code.
The method’s
logPageVisit
parameter must betrue
. This is the default state if you call the method without any parameters.cshtml@using Kentico.Activities.Web.Mvc @* Registers scripts that ensure logging of page-related activities *@ @Html.Kentico().ActivityLoggingScriptV2()
Enabling the UseActivityTracking
feature ensures that the system registers routes that receive activity logging requests.
After adding the code mentioned above, the Page visit activity is logged every time a page is visited, and the Landing page activity is logged every time a visitor opens a page when first viewing the website.
Enable or disable specific activity types
By default, logging is enabled for all activity types. You can disable or re-enable individual activity types at any time:
- Open the Contact management application in the Xperience administration.
- Switch to the Activity types tab.
- Select the activity type that you wish to configure.
- Select or clear the Enabled checkbox.
- Save the activity type.
Activity and contact update processing
When activities or contact detail updates occur, the system initially saves the data into the application memory. This data is then batch processed from the memory into the database every 10 seconds by default.
If your system processes a large number of activities and contact updates, you can consider increasing the default interval:
Edit your project’s configuration file (appsettings.json by default).
Add the
CMSProcessContactActionsInterval
key. Increase the value to reflect how often you want the activities and contact updates to be processed.JSONProcessing activities and contact updates every 30 seconds"CMSProcessContactActionsInterval": 30,
Save the file.
The system now processes activities and contact detail updates according to the configured interval. The interval affects the following:
- How often the application saves logged activities and contact detail updates from the memory into the database.
- How often the system recalculates data that could be affected by activities and contact updates, such as contact groups conditions, automation process triggers, scores, etc.