Playing around with AWStats and Sitecore

This month, I’ve had a chance to play around with AWStats and Sitecore. The main purpose is to provide website statistics of the past days / weeks / years with a friendly user interface to the site admin / web master.

How about Sitecore Analytics? Sitecore License has had NO xDB enabled so they’ve not used Sitecore Analytics since day 1. Of course, the good replacement – Google Analytics – just has been integrated recently.


  • single Sitecore instance
  • is hosted on IIS / Windows web server
  • open source and can run on Windows
  • depends on IIS log files

Step by step set-up guide of AWStats

  1. install Perl if NOT YET
  2. navigate to AWStats Download and then download AWStats version 7.7 (the latest stable version at this moment)
  3. unzip and then copy / paste wwwroot folder to our Sitecore website folder + rename it to awstats for a better practice
    • awstats_1
    • Note: we can add a virtual directory to IIS site and name it awstats instead of copying wwwroot folder to our Sitecore website folder
    • awstats_31
  4. let’s configure AWStats for Microsoft’s IIS server by following this instruction
    • access [Sitecore website folder]\awstats\cgi-bin
    • create a configuration file by clone awstats.model.conf and rename it to awstats.viethoang.conf
    • next step is to edit awstats.viethoang.conf to match our specific environment
  5. change the LogFile value to the full path of our web server log file, for instance: “C:\inetpub\logs\LogFiles\W3SVC39\u_ex200319.log”
    • awstats_4
    • Note 1: we can get the correct folder based on the following info
    • awstats_3awstats_2
    • Note 2: there are many log files so we should merge them all into one single file, otherwise we will have to process one by one to build statistics database
    • awstats_5
    • awstats_6
  6. change the LogFormat to 2
    • awstats_7
  7. change the DirIcons parameter to reflect relative path of icon directory, in this case it should be /awstats/icon
    • awstats_8
  8. set the SiteDomain parameter to the main domain name or the intranet web server name used to reach the web site being analyzed
    • awstats_9
  9. okay it should be enough, let’s process the logs now by following this instruction
    • open Command Prompt and change directory to [Sitecore website folder]\awstats\cgi-bin
    • run perl -config=viethoang
    • awstats_10
    • hopefully, you would see something like this
    • awstats_11
  10. so far so good, let’s view our statistics from a browser
    • navigate to [Sitecore host name]/awstats/cgi-bin/, you may get the following error HTTP Error 404.3 – Not Found
    • awstats_12
    • as our IIS doesn’t know anything about Perl so we need to add the following Script Map via Handler Mappings feature of IIS
    • awstats_13
    • Note: you may get the following error HTTP Error 502.2 – Bad Gateway as you miss “%s” %s in Executable field above
    • awstats_15
    • hopefully, you would see something like this
    • awstats_14


How to update the statistics

We should open [Sitecore website folder]\awstats\cgi-bin\awstats.viethoang.conf and then set the LogFile value to name pattern for the log files are created by IIS, for instance “C:\inetpub\logs\LogFiles\W3SVC39\u_ex%YY%MM%DD-24.log” so AWStats can process the latest + completed log file (normally, it’s the log file of yesterday)

  • awstats_23

Generally, we have 2 ways to keep the statistics updated:

  1. manual update via browser
  2. create a Windows task scheduler for updating the statistics daily + automatically
    • awstats_24

How to secure AWStats

We can follow this instruction as medium secured policy so we should open [Sitecore website folder]\awstats\cgi-bin\awstats.viethoang.conf and then edit it:



  1. ensure that the bandwidth statistics is available by checking Byte Sent and Byte Received logging fields via Logging feature of IIS (note: they might be not checked by default)
    • awstats_22
    • awstats_21
  2. if we want to have our statistics to be indexed, set MetaRobot to 1
    • awstats_30
  3. if end users must go through proxies / load balancers before accessing the web application, the client IP address field (c-ip by default) in IIS log will show the IP address of network device instead of client’s IP address. So we should use X-Forwarded-For request header to log the IP address of the client, e.g we will add a new field manually to IIS log (Ex: X-Forwarded-For) and then update LogFormat of AWStats to map that new field correctly
    • assume that the fields of our IIS log will be like this
    • awstats_32
    • we will update LogFormat in our AWStats config file to this
    • awstats_33

The references


Happy Sitecore Playing!


2 thoughts on “Playing around with AWStats and Sitecore

  1. To let run AWStats on IIS10, you need to use the Script map without “… like this> C:\Perl\perl\bin\perl.exe %s %s in Executable field. (no double quotes).

    Liked by 1 person

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.