Created
November 20, 2015 09:10
-
-
Save fblundun/ff605ac72fdece1513ab to your computer and use it in GitHub Desktop.
Manually sending geolocation events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!geolocationContextAdded && navigatorAlias.geolocation && navigatorAlias.geolocation.getCurrentPosition) { | |
navigator.geolocation.getCurrentPosition(function (position) { | |
var coords = position.coords; | |
var geolocationContext = { | |
schema: 'iglu:com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-1-0', | |
data: { | |
latitude: coords.latitude, | |
longitude: coords.longitude, | |
latitudeLongitudeAccuracy: coords.accuracy, | |
altitude: coords.altitude, | |
altitudeAccuracy: coords.altitudeAccuracy, | |
bearing: coords.heading, | |
speed: coords.speed, | |
timestamp: position.timestamp | |
} | |
}; | |
window.snowplow('trackStructEvent', 'geolocation', 'geolocation_added', null, null, null, [geolocationContext]); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment