matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.9k stars 2.65k forks source link

How to set location parameters (lat, long, city, region, country) without having to specify token_auth #11563

Closed Sobhika2 closed 7 years ago

Sobhika2 commented 7 years ago

Hi ,

We are using the IOS SDK for tracking usage of one of our mobile application PIWIK. However, all mobile devices are localized in the US, even if we access it from Europe. This might be related to the fact that we are routed through Mobile Iron.

We tried sending the location using custom variable as below _paq.push([ 'setCustomVariable', 1 , "Location", location, "page" ]); which did not work.

This project(same source code) is used/launched/deployed on 2 different environments:

So in second case web application is launched in local mobile browser, from file:// protocol, and in addition to this all requests (PIWIK requests too) from this application goes through MobileIron proxy servers. That’s why sending window.location to PIWIK doesn’t help, cause we are sending file://folder /folder/folder as location object, and PIWIK server cannot detect our real – local IP address for location detection.

In conclusion we have question – How to enable PIWIK location detection in our case? We have user coordinates (lon, lat), from mobile device using our app logic, is there way to pass this info to PIWIK and show it on the map?

Please assist.

Regards, Sobhika

mattab commented 7 years ago

We have user coordinates (lon, lat), from mobile device using our app logic, is there way to pass this info to PIWIK and show it on the map?

Yes, this might be possible. This feature is available in our HTTP tracking API, which is used by the iOS SDK. See: https://developer.piwik.org/api-reference/tracking-api#other-parameters-require-authentication-via-token_auth

So if functions to set these values are not available in the iOS SDK yet, please consider submitting a pull request or creating an issue.

Sobhika2 commented 7 years ago

Dear @mattab ,

Thanks, but that produced some questions from my side:

And I still have old question:

Regards, Sobhika

mattab commented 7 years ago

I just realised that currently, setting location details require token_auth authentication so this is not yet suitable for your use case, because token_auth is private and therefore shouldn't appear in the iOS app SDK calls or in the JS calls.

-> Solution would be to make location parameters settable without requiring token_auth either by default, or to introduce a new config setting (or reuse tracking_requests_require_authentication )

mattab commented 7 years ago

Maybe @Sobhika2 you could test this: this workaround solution should let you track city/country/region of your iOS apps users (if you know the country/city by another mean than IP addresses):

brototyp commented 7 years ago

Hi @Sobhika2, just a short information on the state of the iOS SDK here. Neither version 3.x nor the new 4.x release supports setting the Geoposition parameters for an event. Please open a new issue in the piwik iOS SDK repository and we will look into adding it.

mattab commented 7 years ago

@brototyp Maybe geo location function don't need to be added to the SDK yet because currently it's not really supported by Piwik core without changing a config setting, which is not recommended. By default setting location details require token_auth authentication but we can't put such token_auth in the iOS app compiled code.

instead we would need

  1. a new iOS SDK method to set the custom parameter. Created an issue https://github.com/piwik/piwik-sdk-ios/issues/153
  2. a new way to allow Mobile Apps users to override geo location information. For example via a new config file setting (enable overriding geo location without token auth) or it automatically for mobile apps measurables in Piwik (this issue)
brototyp commented 7 years ago

@mattab Yes, thank you for the idea for the piwik/piwik-sdk-ios#153 Issue. That sounds like a really good idea!

mattab commented 7 years ago

Let's continue discussion in https://github.com/piwik/piwik-sdk-ios/issues/153

iPiyushBaranwal commented 4 years ago

Hi All, my question is How to set location parameters (lat, long, city, region, country) from ios/android side to the Matomo dashboard. I tried to set up but by default its Unknown. As when ever i am tracking the event from web Application location is setting as (by default) "us" and automatically flag of "us" is placed on the provided place, but when using ios or Android app default value of location is unKnown.

tsteur commented 4 years ago

See previous comment https://github.com/matomo-org/matomo/issues/11563#issuecomment-304547116 and also https://matomo.org/docs/geo-locate/ otherwise if you want to location to be detected automatically

IamMille commented 11 months ago

Can someone explain why using JavaScript it is possible to set the user but not the location?