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 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 form. 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 removes any UTM parameters from the URL values logged for such activities (utm_campaign, utm_source, 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 action on the tracked website.

Logged via cross-site tracking or the headless tracking API.

Data input

datainput

The visitor entered data through a specific input. For example, such activities can be logged in cross-site tracking scenarios when a visitor submits information through a form on an external site.

Logged via cross-site tracking or the headless tracking API.

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.

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.

  1. Open your project in Visual Studio.

  2. Edit the Program.cs file.

  3. Enable activity tracking by calling the UseActivityTracking method of the IFeaturesBuilder delegate. Pass the delegate as an argument to AddKentico.

    
    
    using Kentico.Activities.Web.Mvc;
    using Kentico.Web.Mvc;
    
    ...  
    
    WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
    
    ...
    
    builder.Services.AddKentico(features =>
    {
        features.UseActivityTracking();
    });
    
    
  4. 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 be true. This is the default state if you call the method without any parameters.

      
      
        @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:

  1. Open the Contact management application in the Xperience administration.
  2. Switch to the Activity types tab.
  3. Select the activity type that you wish to configure.
  4. Select or clear the Enabled checkbox.
  5. 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:

  1. Edit your project’s configuration file (appsettings.json by default).

  2. Add the CMSProcessContactActionsInterval key. Increase the value to reflect how often you want the activities and contact updates to be processed.

    Processing activities and contact updates every 30 seconds
    
    
     "CMSProcessContactActionsInterval": 30,
    
     
  3. 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.