Error using GA with Redis session provider

Fixed in

EPiServer.GoogleAnalytics 2.2.1


May 09, 2018


Jun 14, 2018


Closed, Fixed and tested


We have the session provider configured to use a Redis instance on the Azure cloud. The configuration uses a custom "redisSerializerType", a simple class doing serialization / deserialization using Newtonsoft.Json, rather than the default binary serializer that ships with the Microsoft.Web.Redis library.

The error occurs when you logout. The error message is:

Unable to find a constructor to use for type EPiServer.GoogleAnalytics.Web.Tracking.AnalyticsInteraction. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path '$values[0].ContentLink', line 1, position 268.

Steps to reproduce

1. Install Redis server.
2. Install a Quicksilver site.
3. Install the package Microsoft.Web.RedisSessionStateProvider.
4. Add JsonSerializer.cs to project.
5. Modify the web.config file as shown below:

<sessionState mode="Custom" customProvider="MySessionStateStore">
    <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="" accessKey="" ssl="false" redisSerializerType="EPiServer.Reference.Commerce.Site.JsonSerializer, EPiServer.Reference.Commerce.Site" />

6. Add the following code to CheckoutController.cs, before last line of action Purchase:

System.Web.HttpContext.Current.AddAnalyticsTransaction(purchaseOrder as PurchaseOrder, ContentReference.StartPage);

7. Build and run the site.
8. Place an order ==>See exception.