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”.
The way visitors are identified is as follows:
A sessionHash is created as hash(siteID + User-Agent + IP).
Store this in memory as a sessionHash→UUIDv4 map for 8 hours.
Store a UUIDv4→seen_paths map (again in memory), so we can count new visitsfor new paths.
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
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