Mapping the Web analytics storage folder to the server file system

If your project is connected to the Azure Blob Storage (Azure projects deployed to Cloud Services by default and other projects using the <add key=“CMSExternalStorageName” value=“azure” /> web.config key), then the system also stores web analytics logs on the blob storage. The Web analytics module writes and processes logs every minute, which can cause problems on the blob storage with latencies. Moreover, the Web analytics module can create a large number of files, which further degrades the performance of the blob storage.

We highly recommend that you map the folder which stores Web analytics data to the file system of the server:

  1. Open your project in Visual Studio.

  2. Create a new class in the App_Code folder or CMSApp_AppCode -> Old_App_Code on web application projects.

  3. Use the following code to map the Web analytics storage to the local file system (in ~/App_Data/CMSModules/WebAnalytics). See Storing files in different containers for further explanations.

     using CMS.IO;
     using CMS.Base;
     public partial class CMSModuleLoader
         private class CustomStorageAttribute : CMSLoaderAttribute
             /// <summary>        
             /// The system executes the Init method of the CMSModuleLoader attributes when the application starts.
             /// </summary>
             public override void Init()
                 // Creates a new StorageProvider instance with the default Windows file system provider
                 AbstractStorageProvider webAnalyticsProvider = new StorageProvider();
                 // Maps a directory to the provider
                 StorageHelper.MapStoragePath("~/App_Data/CMSModules/WebAnalytics", webAnalyticsProvider);
  4. Save the file. If your project is installed in the web application format, rebuild the solution.

  5. If your project is deployed to Azure, re-deploy your project.

The Web analytics module now stores its log in the server’s file system instead of the blob storage.