In many cases it’s important to log the location of a user and associate that location with other events. The mParticle SDK allows you to include detailed location information with all of your events.
There are two ways to approach location tracking:
startLocationTrackingmethod and let the mParticle SDK collect and update location information for you. Remember to call
stopLocationTrackingwhen you no longer need to track location
locationproperty directly. In this case you are responsible for maintaining
locationupdated and setting it to
nil/nullwhen no longer needed
startTrackingLocation() initializes HTML 5 Location Tracking. The user will be prompted to allow access to location. The mParticle SDK will then start listening to the location events. Thereafter, the location will be appended to events are sent to the mParticle servers.
//start tracking location mParticle.startTrackingLocation(); //stop tracking location mParticle.stopTrackingLocation(); // manually set coordinates that were retrieved from another source mParticle.setPosition(40.71, 74.00);