Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Length of time page is viewed

Featured Replies

Recently got a sponsor for one of the pages on a site I am working on. Normally I could provide info to the sponsor on how often the page was shown with there ad on it, however due to the nature of the page (it refreshes itself) I am wondering if it is possible to work out how long a page was displayed for. The sponsor has not requested any information but I would like to have it on hand if they ever do. Chances are the page will be viewed for around 1 hour 45 mins by maybe 30 or so peope (initailly) and rather than say the page was viewed 30 times I would like to be able to say your ad was shown for X amount of hours. The whole page doesnt refresh itself, just a certain part of it.

 

Thanks in advance.

1 hour 45 minutes is a little excessive, andthing over a couple of minutes is extremely rare and normally due to someone leaving your page on while they do other stuff.

 

If you want to time individual ads you're need to implement some sort of timer script, and even then that's going to be very complicated to measure page time, finding out if the particualr ad was displayed, and then calculating the ad display time.

 

If the ad is static (ie always on that page) you could easily get the total time for that page from a decent stats package. I'd suggest removing the page refresh, there's no reason to use one.

I'm assuming the page displays a football game and hence the 1hr 45 mins timing.

 

Don't know the answer to the question though.

  • Author
I'm assuming the page displays a football game and hence the 1hr 45 mins timing.

 

Don't know the answer to the question though.

Yep the page offers live text updates on a football game and from tests run and feedback most people have the page open for all of the match. It is 1 static sponsors logo on the page.

Sounds like you need some statistics tool that can show session length for you. I'm hosted with Fasthosts and that comes with Matrixstats for free which will show me the session time spent on my website.

 

Im sure there must be others out there you could use, perhaps even google analytics.

 

 

Alternatively if your handy with PHP you could do somthing similar yourself. Store the time in a session variable first time the page is loaded and enter it into a database along with the session id. Now every time your page refreshes you could add or update the refresh time in the database for the session id record. By comparing the start and last recorded refresh you would have a fairly accurate idea of how long was spent. It would all depend on how often the refreshes happen ofcourse.

 

I hope that made sense, its early and ive not yet had coffee :huh:

  • Author
Sounds like you need some statistics tool that can show session length for you. I'm hosted with Fasthosts and that comes with Matrixstats for free which will show me the session time spent on my website.

 

Im sure there must be others out there you could use, perhaps even google analytics.

Alternatively if your handy with PHP you could do somthing similar yourself. Store the time in a session variable first time the page is loaded and enter it into a database along with the session id. Now every time your page refreshes you could add or update the refresh time in the database for the session id record. By comparing the start and last recorded refresh you would have a fairly accurate idea of how long was spent. It would all depend on how often the refreshes happen ofcourse.

 

I hope that made sense, its early and ive not yet had coffee :huh:

Ye it makes sense thanks, was trying various things with sessions after posting my question here. Ive not found a solution yet but ill keep going. Its not quite as complicated as you suggest though. As only part of the page refreshes the logo is constantly on the screen.

I hate to suggest this but how about an i-frame for the information so that rather than the whole page updating only the iframe does and that way you have more control over your ads :)

  • Author

Certain part of the page uses ajax to update, really don't want to change away from that if possible. As I said the sponsors have not asked for info but would be nice to have it at hand if possible. I will keep looking at possibilities using sessions at the moment as it seems that would be the easiest way to do it. Was also thinking of maybe having a timer hidden on the page. When the page is closed or nevigated away from then I could possibly store the value of the timer. Not sure how feasible this is but I might give it a try. I'm sure there are many possible ways of doing this and I am determind to find at least one custom way of doing. Anyways thanks for the suggestions guys.

The way i suggested should work regardless of whats being updated. If your updating an image you could still use a method similar to mine as the image link would be to a php file that does it stuff, then sends the headers for the image to display it.

 

<img src="myimage.php" height="2" width="2" alt="" />

 

<?php

// do calc/timer stuff here

Header("Content-type: image/jpeg");
Header("Location: myimage.jpg");
Exit();
?>

  • 2 weeks later...
  • Author

In case anyone was wondering how I solved this, I thought I'd post a solution. Thanks for all the suggesions guys but I took an easy way out. Every time the script to refresh the page was called it invoked a counter. Simple really it didn't count the page refresh as one but 10 (refreshed every 10 seconds). Now in the admin area of my site I can see the value that is stored in proper time format. The calculation simply turns the stored seconds into days hours mins and seconds after 5% is of the seconds are removed. I thought 5% would more than compensate for the people who navigated away from the page during refreshes. I print the stats weekly and just reset the value seconds value in the db to 0. May not be the most elegant solution but it works pretty well.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.