Hits on Images


AWStats reports include a standard list of hits on the web site pages. The web site pages are all URL’s ending with .htm, .html, .php, .asp,… Images and multimedia contents are not pages.

If images are important in your web site, you need to know which images are the most shown.

This extra section lists the most popular images of your web site.

You can add the Extra Section below at the end of your awstats.your-domain-name.conf configuration file.

New Report

AWStats, hits on images
This AWStats screen has been simulated for better readability.

Extra Section

ExtraSectionName1="Hits on Images"
ExtraSectionCodeFilter1="200 304"
ExtraSectionCondition1="URL,\.(png|gif|jpe?g)$"
ExtraSectionFirstColumnTitle1="Image"
ExtraSectionFirstColumnValues1="URL,^(\/.*\.(png|gif|jpe?g))$"
ExtraSectionFirstColumnFormat1="<A HREF='http://www.your_site.com%s' TARGET='_blank'>%s</A>"
ExtraSectionStatTypes1=HBL
ExtraSectionAddSumRow1=1
MaxNbOfExtra1=10
MinHitExtra1=1

Replace www.your_site.com by the address of your site.

MaxNbOfExtra1 is the number of lines that will be listed. Use the most convenient value.

19 Responses to “Hits on Images”

  1. Drax says:

    I added that extra section in my awstats.your-domain-name.conf but I dont get any data on the reports… the new fields are shown in the stats but they are all empty… all other normal fields of awstats updates normally.

    Do I have to chenge something on the Apache logs or what?

    Thanks a lot and this is a very usefull site 😉 congratulations!

  2. Jean-Luc says:

    I copied the section in an AWStats config file and I got the same result as you! This was caused by WordPress replacing my " (quotation mark) by ” (right double quotation mark) and my ' (apostrophe) by ‘ (left single quotation mark).

    I have found a work-around and I just updated the extra section accordingly. You should now be able to copy it and paste it in your AWStats config file without problem.

  3. Drax says:

    Thanks a lot for your answer!! that little detail solved my problems… now it works!

    Thanks again!

  4. ChojinDSL says:

    Hi there. I’ve noticed that your ExtraSection config parses ALL images on the server. This is including those which AWstats uses as icons to display for its statistics.

    (Im a total noob when it comes to regexp)

    Is there an easy way to restrict the image statistics to a specific subdirectory (include all subdirectories benath it)?

    e.g./var/www/example.com/images/
    and this would include all subdirectories such as:
    /var/www/example.com/images/old/
    /var/www/example.com/images/new/
    /var/www/example.com/images/photshopped/

  5. Jean-Luc says:

    Try this:

    ExtraSectionFirstColumnValues1=”URL,^(\/images\/.*\.(png|gif|jpe?g))$”

    It will only count the images under /images.

  6. Nico says:

    Hi Jean-Luc, I am trying to add to my ExtraSection a filter that contain only mp3 download files, but I cant.
    the url that appear in my log is like this:
    GET /download.php?archivo=file.mp3

    I just added the URLWithQuery=1 in my cfg file, but nothing appear in my extra section
    How can I do it?

    Thanks

  7. Jean-Luc says:

    You need to use URLWITHQUERY in the extra section:

    ExtraSectionCondition1=”URLWITHQUERY,^\/download\.php\?archivo\=\w+\.mp3$”

    ExtraSectionFirstColumnValues1=”URLWITHQUERY,^\/download\.php\?archivo\=(\w+)\.mp3$”

  8. courtney says:

    Jean-Luc

    Must commend you on some terrific code.
    Pasted it into awstat and it worked just as promised.
    It tracks all images in a specific folder/entire site.
    Is it possible to use the same code to track hits on specific images served?
    Would like to have it track multiple images to supply advertisers with a monthly report on number of times their image appeared on the site.

    Thanks again
    Courtney

  9. Steve says:

    I’m having a bit of trouble with the code. While I get a new section ‘Hits on Images’ the results come back as URLs. Not images – any ideas?

    Question moved to our forum about Extra Sections: trouble with ‘Hits on Images’.

  10. Website Designer says:

    Hi! Nice 🙂 I tried adding the extra section as you’ve instructed, and the new fields are shown in the stat.. (which are blank) and after 1 day when awstat updates, the ‘hits on image’ fields disappear.

    Any idea?

  11. Jean-Luc says:

    Hi,

    That can happen in systems using cPanel. Have a look at Changing Config File in cPanel. The article explains several possible work-arounds.

  12. Joakim Berglund says:

    You saved me a lot of work here, friend!

    I’ve been googling for days to find a solution, and now (05:08 in the night/morning) I thought I’d just give it one more shot before sleep, and found this. I was just about to give up.

    I’ll try that part with only counting images in a subfolder tomorrow. Great stuff.

    Works exactly as promised, can’t thank you enough!

  13. Babel says:

    hi,

    thank you very much it works! but how can i see the whole list? like in my sites-section – i can see the whole list and can filter!

    thx

  14. Babel says:

    me again. i want to see all .zip and .rar files!

    _________________________________
    # Extra Section for all file types
    ExtraSectionName1=”Hits on Files”
    ExtraSectionCodeFilter1=”200 304″
    ExtraSectionCondition1=”URL,\.(rar|zip)$”
    ExtraSectionFirstColumnTitle1=”File”
    ExtraSectionFirstColumnValues1=”URL,^(\/.*\.(rar|zip))$”
    ExtraSectionFirstColumnFormat1=”%s
    ExtraSectionStatTypes1=PL
    ExtraSectionAddSumRow1=1
    MaxNbOfExtra1=120
    MinHitExtra1=1
    _______________________________

    it doesnt work 😐 why? i see only all images!

  15. Babel says:

    ok now it works thx 😀

  16. Richard Cummings says:

    Searching for how to view the hits on all of my images files using AWSTATS. This configuration did the trick…thx so much for the information!

  17. Shane says:

    I used this code snippet for showing the top images, as-is, only changing the domain name as needed, but the images area does not show up in my web stats generated by AWSTATS.

    is there something I need to do to make it show up besides insert that code block in the bottom of the file?

  18. Shane says:

    Never mind my earlier post… was running 6.6.x version of AWSTATS and had to upgrade to the latest and now it looks like it will work.

  19. IT Spud says:

    Tried the MP3 variation of the above code ideas, and have a major disparity to understand.

    The numbers reported for ‘hits’ vs. ‘pages viewed’… Before investigating the extra section, I decided to remove both MP3 and XML file extensions from the ‘NotPageList’… The numbers I get for Page Views is very different.

    (…)

    Question moved to our forum about Extra Sections: major disparity when counting hits on MP3 and XML files.


 

Leave a Reply

You must be logged in to post a comment.