Skip to content

Use data from your Kentico Xperience website in Looker Studio reports.

License

Notifications You must be signed in to change notification settings

Kentico/xperience-google-lookerstudio

Repository files navigation

Kentico.Xperience.Libraries 13.0.0 Stack Overflow

Xperience Looker Studio Integration

Create flexible Looker Studio reports which display data from your Xperience website. For example, these reports can show information about contacts and their activities, email marketing statistics, and more. Please see our Terms of Service and Privacy Policy for more information about how your data is used.

Use the following process to set up the integration:

  1. Install the module into your Xperience administration project.
  2. Configure exactly which types of data will be available for Looker Studio and generate the report.
  3. To comply with personal data protection policies, set up consents and data anonymization.
  4. Create Looker Studio reports and add a data source using the Kentico Xperience connector.

Sample report

Compatibility and Prerequisites

  • Kentico Xperience 13.0.0 or newer.
  • The integration works via the Xperience administration project.
    • The development model used for the live site does not affect the integration, and both ASP.NET Core and MVC 5 are supported.
    • Your Xperience administration project must be publicly accessible (not running on an internal network).
  • Your application must regularly process scheduled tasks.

Installation

  1. Download the Kentico.Xperience.Google.DataStudio ZIP package by locating the latest Release.
  2. In the Xperience administration, open the Sites application.
  3. Import the downloaded package.
    • Make sure the Import files and Import code files settings are enabled.
  4. Perform the necessary steps to include the following imported folder in your project:
    • /CMSModules/Kentico.Xperience.Google.DataStudio

Generate the report in Xperience

To reduce the number of database queries required to display your Xperience data, the Looker Studio integration generates a physical JSON file in the App_Data/CMSModules/Kentico.Xperience.Google.DataStudio directory. This file is generated by the scheduled task Generate Google Data Studio report, which is configured to run daily by default.

To begin using the Looker Studio connector immediately after installing the integration, go to the Scheduled tasks application and manually execute the task.

Configure report fields

The generated report contains certain fields by default, which you can find in DefaultDataStudioFieldSetProvider.cs. The report fields are defined by FieldSets which represent a single object type (like contacts) and its fields which are represented by a list of FieldDefinitions.

If you wish to modify the default list of fields, create a custom implementation of IDataStudioFieldSetProvider. The class must be added under the CMS\Old_App_Code folder of your Xperience administration project.

Define the GetFieldSets method. For example, if your reports only need to display contacts and activities, you can remove the other default FieldSets:

[assembly: RegisterImplementation(typeof(IDataStudioFieldSetProvider), typeof(CustomFieldSetProvider), Lifestyle = Lifestyle.Singleton, Priority = RegistrationPriority.Default)]

namespace MySite.LookerStudio
{
    /// <summary>
    /// Custom implementation of <see cref="IDataStudioFieldSetProvider"/>.
    /// </summary>
    public class CustomFieldSetProvider : IDataStudioFieldSetProvider
    {
        public IEnumerable<FieldSet> GetFieldSets()
        {
            return new FieldSet[]
            {
                DataStudioConstants.activityFieldSet,
                DataStudioConstants.contactFieldSet
            };
        }

You can also add/remove FieldDefinitions from the default FieldSet.Fields properties, or create your own custom FieldSets. For example, to add products to the report you can create a new FieldSet which contains the fields you are interested in displaying:

public IEnumerable<FieldSet> GetFieldSets()
{
    return new FieldSet[]
    {
        DataStudioConstants.activityFieldSet,
        // Other FieldSets...
        new FieldSet {
          ObjectType = SKUInfo.OBJECT_TYPE_SKU,
          DateFilterField = nameof(SKUInfo.SKUCreated),
          Fields = new FieldDefinition[]
          {
              new FieldDefinition {
                  Name = nameof(SKUInfo.SKUID),
                  DataType = DataStudioFieldType.TEXT,
                  Anonymize = true
              },
              new FieldDefinition {
                  Name = nameof(SKUInfo.SKUCreated),
                  DataType = DataStudioFieldType.YEAR_MONTH_DAY_SECOND
              }
          }
        },
    };
}

💡 When creating a new FieldSet, always include the DateFilterField if supported by the object type, and include that field in the Fields list. This ensures that reports can display the correct data for the selected timeframe. This field is generally the object's "created on" date - SKUInfo.SKUCreated for products in the example above.

Data protection

Because the personal information of your visitors is transmitted to Google's servers, it is important to keep GDPR and other data protection regulations in mind while using this integration. By default, this integration protects your visitor's data using two approaches:

  • Anonymizing (hashing) identifiers
  • Checking consent agreements

Consents

If you are collecting data about your visitors on your website (e.g. via forms or activities), you should already have one or more consents active. We recommend creating another consent which notifies visitors that their data may be sent to Google for reporting purposes. This integration will automatically remove contacts and their activities from the report if they have not agreed to this consent.

To configure the consent requirements for the Looker Studio integration:

  1. Prepare a suitable consent in the Xperience Data protection application, and provide a way for visitors to give agreements.
  2. Open the Settings application.
  3. Navigate to Integration → Google Data Studio.
  4. Select your consent in the Required consent setting.
    • The default value "(none)" means the integration will not check consent agreements and all contacts/activities will appear in the report.
    • If you select a consent from the list, only the data of contacts who agreed to that consent will appear in the report.
  5. Click Save.

Anonymization

By default, the Looker Studio integration will anonymize the IDs of all data records, such as a contact's ID. When the report is generated, the IDs will be hashed using a salt that is discarded after the report is finished generating. This ensures that a record in the report cannot be correlated to any specific record in your database.

If you are creating your own FieldDefinitions, we recommend setting Anonymize to true for any field containing an ID:

new FieldDefinition {
    Name = nameof(ContactInfo.ContactID),
    DataType = DataStudioFieldType.TEXT,
    Anonymize = true
}

Customize data protection

If additional functionality is required to protect your visitor's data, it can be implemented by your developers. Aside from customizing the fields in the report, you can also implement your own anonymization method and limit the data in the report. Create a custom implementation of IDataStudioDataProtectionService under the CMS\Old_App_Code folder of your Xperience administration project:

[assembly: RegisterImplementation(typeof(IDataStudioDataProtectionService), typeof(CustomDataProtectionService), Lifestyle = Lifestyle.Singleton, Priority = RegistrationPriority.Default)]

namespace MySite.LookerStudio
{
    /// <summary>
    /// Custom implementation of <see cref="IDataStudioDataProtectionService"/>.
    /// </summary>
    public class CustomDataProtectionService : IDataStudioDataProtectionService {

Add the Xperience data source to Looker Studio reports

When creating a new Looker Studio report or adding a data source to an existing report, choose the Kentico Xperience connector.

Xperience connector

Once you authorize the connector, you will be asked to provide the following:

  • A Path which is the absolute URL of your Xperience administration website, e.g. https://myadmin.com.
  • The username and password of an Xperience user to authenticate all Looker Studio requests. The permissions of this user are not checked. This requirement ensures that there are no unauthorized requests to access your report data.

⚠️ If the authentication parameters change (e.g. the user is deleted in Xperience), you must revoke access to the connector and re-authenticate. You can find more information about revoking access in the Data credentials article.

After you have properly authenticated, you can begin using the data source in report controls like tables. You can find more information about building reports in Google's documentation, such as the Table reference. One concept that we recommend you read carefully are Looker Studio's blends. If you are familiar with SQL, this is similar to performing a JOIN on multiple tables and will help you retrieve the data you need in your reports.

For example, let's say you want to display a table listing the latest form submission activities on your site with the email address of the contact that submitted the form. To accomplish this, you can create a new blend with two tables: one containing the activity data, and one containing the contact data. In the Configure join menu, link the "ActivityContactID" field from one table to the "ContactID" field of the other table. In the activity table, add a filter to load only the activities where "ActivityType" equals "bizformsubmit," then add any other dimensions you'd like to display. Once finished, it could look something like this:

Blend example

💡 The ContactEmail field is not available by default. If you want to follow the above example, you need to add the field to your report.

Contributing

Please see CONTRIBUTING.md for more information.

License

Distributed under the MIT License. See LICENSE.md for more information.

Questions & Support

See the Kentico home repository for more information about the products and general advice on submitting questions.