goatcounter icon indicating copy to clipboard operation
goatcounter copied to clipboard

pageviews from backend don't follow "Track unique visitors for up to 8 hours" setting

Open steveja42 opened this issue 2 years ago • 2 comments

I am sending pageviews from a nodejs backend and the "Track unique visitors for up to 8 hours" setting doesn't seem like it is being followed. When I visit the same page several times from the same computer, goatcounter shows it as having multiple visits instead of just 1 visit as I expected.

const data = {
	no_sessions: false,
	hits: [
		{
			ip,
			path,
			"user_agent": req.headers["user-agent"]
		}
	]
}

try {
	const response = await fetch('https://owir.goatcounter.com/api/v0/count', {
		method: 'post',
		body: JSON.stringify(data),
		headers: {
			'Content-Type': 'application/json',
			Authorization: `Bearer ${token}`
		}
	}); ...

steveja42 avatar Nov 17 '22 02:11 steveja42

Are you sure the ip and user_agent fields are set? Does it return an error if you drop the no_sessions parameter?

What is the actual request it sends?

arp242 avatar Nov 17 '22 19:11 arp242

Still happens after dropping no_sessions. I deleted all the pageviews, sent the following and then gc showed 2 views for / and 1 view for /about .

Nov 17 05:01:48 PM
{"hits": [{
	"ip": "70.179.129.22",
	"path": "/",
	"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
}]}

Nov 17 05:01:57 PM
{"hits": [{
	"ip": "70.179.129.22",
	"path": "/about",
	"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
}]}

Nov 17 05:04:44 PM
{"hits": [{
	"ip": "70.179.129.22",
	"path": "/",
	"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
}]}

steveja42 avatar Nov 17 '22 23:11 steveja42