Movatterモバイル変換


[0]ホーム

URL:


Sessions and visitors

GoatCounter only counts “visits” rather than “pageviews”:

  • A “pageview” is every time a page is loaded.

  • A “visit” is the first time someone loads a page. Someone reloading the pageor going to another page and then coming back is counted as one visit.

You almost always want to keep track of visits rather than pageviews. Otherwisesomeone reloading the page ten times will show up as ten times, which is notreally meaningful.

This can be disabled in the site settings, atSettings → Data collection →Sessions. If it’s disabled every pageview counts as a “visit”.

Technical details

The way visitors are identified is as follows:

  1. A sessionHash is created as hash(siteID + User-Agent + IP).

  2. Store this in memory as a sessionHash→UUIDv4 map for 8 hours.

  3. Store a UUIDv4→seen_paths map (again in memory), so we can count new visitsfor new paths.

  4. Use the UUIDv4 in the database and such.

The IP address and User-Agent are never stored to the database or disk, andthere is no conceivable way to trace the random UUID back to this.

It’s only stored in memory, which is needed anyway for basic networking to work.


Or in pseudo-code:

session_key    = site_id + user_agent + IPcount_as_visit = false# We've seen this session before.if sessions[session_key] and sessions[session_key].newer_than(8_hours)    # Only count as visit if this session hasn't visited this path yet.    if not sessions[session_key].seen_path(current_path)        count_as_visit = true        add_current_path(sessions[session_key])    endelse    # Generate new session.    sessions[session_key] = create_random_uuid()    add_current_path(sessions[session_key])    count_as_visit = trueend# Store pageview; only the random UUID in sessions[session_key] is stored,# and NOT session_keystore_pageview()# Increate counter to make the charts go up.if count_as_visit    increase_counter_in_database()end

Questions or problems?

Feel free to get in touch if you’ve got any questions or having any problems; alot of times they can be resolved without too much problems.

Ways to contact me:show

  • Open aGitHubissue. It’s fine to use this for support requests or generalquestions, as GitHub issues are public and the answers may be useful forothers in the future.
  • Email:support@goatcounter.com.
Send message


Make sure this is correct


Just to verify that you’re human



[8]ページ先頭

©2009-2025 Movatter.jp