Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Sobhika2 opened this issue Mar 30, 2017 · 11 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@Sobhika2
Copy link

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:

  • web version (web-ite.swissre.com/webapp/opm) train/prod, here PIWIK works fine in all aspects.
  • mobile version, inside of special web container on top native app.

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
Copy link
Member

mattab commented May 8, 2017

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.

@mattab mattab closed this as completed May 8, 2017
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label May 8, 2017
@Sobhika2
Copy link
Author

Sobhika2 commented May 9, 2017

Dear @mattab ,

Thanks, but that produced some questions from my side:

  • is it possible to send same parameters from JS (using _paq.push)?
  • if there is no JS "built in" way, can I create simply img tags elements with url for piwik.php and with same parameters as from HTTP Api (same as in case if there is no JS support in browser)?

And I still have old question:

  • I am already sending detected location as string in custom variable (ex Latvia, Switzerland etc), I can see it in custom variables list, but those locations are NOT linked to any visitor? Could you explain why its not linked?

Regards,
Sobhika

@mattab mattab reopened this May 12, 2017
@mattab
Copy link
Member

mattab commented May 12, 2017

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 mattab changed the title Piwik Location Tracking for IOS Applications How to set location parameters (lat, long, city, region, country) without having to specify token_auth May 12, 2017
@mattab
Copy link
Member

mattab commented May 28, 2017

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):

  • in your config/config.ini.php below [General] add
; Allow setting geo location (country, city, region) when tracking iOS apps
; Note: this is not recommended but temporary workaround waiting for better solution in https://github.com/piwik/piwik/issues/11563
tracking_requests_require_authentication=0
  • Then in your iOS Apps you can set the country / city of a user by calling the SDK method equivalent to setCustomTrackingParameter in PHP. Then you can track country and city like setCustomTrackingParameter('city', 'Tokyo'); and setCustomTrackingParameter('country', 'Japan'); (full list of geo location parameters in API reference)

@brototyp
Copy link
Member

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
Copy link
Member

mattab commented May 29, 2017

@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 Setting a custom tracking api parameter matomo-sdk-ios#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
Copy link
Member

brototyp commented Jun 3, 2017

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

@mattab
Copy link
Member

mattab commented Jun 21, 2017

Let's continue discussion in matomo-org/matomo-sdk-ios#153

@mattab mattab closed this as completed Jun 21, 2017
@iPiyushBaranwal
Copy link

iPiyushBaranwal commented Jun 1, 2020

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
Copy link
Member

tsteur commented Jun 1, 2020

See previous comment #11563 (comment) and also https://matomo.org/docs/geo-locate/ otherwise if you want to location to be detected automatically

@IamMille
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

6 participants