@Sobhika2 opened this Issue on March 30th 2017

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 commented on May 8th 2017 Member

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 on May 9th 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 commented on May 12th 2017 Member

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 on May 28th 2017 Member

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 commented on May 29th 2017 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 commented on May 29th 2017 Member

@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 on June 3rd 2017 Member

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

@mattab commented on June 21st 2017 Member
@iPiyushBaranwal commented on June 1st 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 commented on June 1st 2020 Member

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

This Issue was closed on June 21st 2017
Powered by GitHub Issue Mirror