@damianmoore opened this Issue on November 24th 2019

I have a situation where I send tracking requests from the server on behalf of user. To make sure I track the user's correct IP address rather than my own server's address, I add the cip parameter to the request as referred to here. I've noticed that since doing this, the user's IP addresses are not geo-coded to have a country any more and just display as 'Unknown' with a question mark.

The code I am using can be viewed here. If you want a bit more background on my reasoning you can read the description of my GitHub project called Matomo Monorail.

I believe that if the cip parameter is included, this should be what gets fed into the GeoIP database. I have other sites tracking to the same Matomo installation via JS directly so am sure the country detection is working.

I'm using Matomo version 3.12.0 from the official Docker image (matomo:3.12.0-apache).

@tsteur commented on November 24th 2019 Member

Hi there, I recommend you check if

  • You have "Use anonymized IP for visit enrichment" enabled in privacy => anonymise data
  • Make sure your requests are authenticated with a token having at least "write" permission

From what I can see in the code this should work and we're actually using this in many places ourselves and don't have any issues with it.

@damianmoore commented on November 28th 2019

Hi @tsteur, thanks for your reply. Can't find "Use anonymized IP for visit enrichment" exactly but "Anonymize Visitors' IP addresses" is unchecked - is this the same? Couldn't seem to see anything similar in global.ini.php either.

For the token permissions, under "API Authentication Token" I can only view or regenerate. Visits are definitely being logged though so I assume this means it has write permissions.

I've updated to version 3.13 in case these settings changed names but doesn't look like it.

@tsteur commented on November 28th 2019 Member

Visits are definitely being logged though so I assume this means it has write permissions.

This does not mean the token was write permission. You'll need to double check if the token auth is correct, and whether the user for that token has write permission (eg a super user can check this but you can also check if that user has permission to create for example Goals).

@sgiehl commented on November 29th 2019 Member

@damianmoore Which GeoIP location provider have you configured in Matomo?

@damianmoore commented on December 3rd 2019

@tsteur I can confirm the token_auth is correct and it belongs to the role for this user under "Manage Users" shows as "Super User".

@sgiehl The GeoIP stuff is baked into this Dockerfile which appears to be MaxMind's GeoLite2-City.

This screenshot is of the site where Matomo requests are proxied with cip and token added by the backend.

This screenshot is of a different site where requests go directly to Matomo and countries are detected from header IP.

Any other ideas for things I can check?

@tsteur commented on December 5th 2019 Member

@damianmoore I would recommend to maybe enable tracker logging for a short time to investigate the issue further:

See https://developer.matomo.org/api-reference/tracking-api#debugging-the-tracker on how to enable tracker debug. (should be only enabled for a short time since this may be visible to your users if someone was to actually look at the response of tracking requests)
And you maybe want to enable logging to file see https://matomo.org/faq/troubleshooting/faq_115/ so you can see what happens for the requests that use cip.

@mattab commented on December 24th 2019 Member

Any update maybe @damianmoore - do you still experience the issue?

@damianmoore commented on March 30th 2020

I've just figured out what was happening when I reported this issue and now have it all working without changing my API calls to Matomo. I had wrongly thought I had Geocoding set up because I saw countries displayed for other sites I had on my Matomo installation. I hadn't realised that Matomo infers country from browser language and I was not including this header when calling the API myself. Now I have DBIP configured correctly I have countries and much more accurate city level data.

@tsteur commented on March 30th 2020 Member

Awesome, thanks for letting us know @damianmoore

This Issue was closed on January 21st 2020
Powered by GitHub Issue Mirror