I have setup a javascript tracker in my web app but still not getting geolocation data in database. I have installed the plugin using following command:
npm install @snowplow/browser-plugin-geolocation
Below is my javascript tracker:
<script type="text/javascript" async=1>
;(function(p,l,o,w,i,n,g){
if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
n.src=w;g.parentNode.insertBefore(n,g)}
}(
window,
document,
"script",
"sp.js",
"snowplow")
);
snowplow("newTracker", "bt-app", "https://collector.example.com", {
appId: "bayanatspeech", // you can specify your own app name here
platform: "web",
forceSecureTracker: false,
contexts: {
webPage: true, // this sets a unique id for each page view
performanceTiming: true, // this captures performance metrics like load times
geolocation: true,
}
});
snowplow("enableGeolocationContext");
// send first heartbeat after 10 seconds, and every 10 seconds thereafter
snowplow("enableActivityTracking", 10, 10);
snowplow("enableLinkClickTracking");
snowplow("trackPageView");
</script>
Thats looks correct are you sure you have not denied the prompt previously? or maybe you have accepted the prompt, if so for that domain it will not ask again.
From Chrome, check here:
On your computer, open Chrome .
At the top right, click More. Settings.
Click Privacy and security. Site Settings.
Click Location.
Choose the option you want as your default setting.
I have created IP lookup enrichent file and set it up postgre loader server. Now I have made this change after the snowplow creation , so do I have to res setup the pipeline? My pipeline is on AWS.
I’ve ran your code above on local host (with my tracker and collector), both on Firefox and Chrome. I’m on a Mac and I received the browser prompt to allow my location to be shared, however on the address bar on the right there was red icon, I had to go into to Security & Privacy > Location Services and allow Chrome and Firefox to share in the location service. Looking on Google for Window’s 10 and 11, the OS also has something similar.
Also to @mike point do you see the context show up in the Snowplow Inspector; it is carried on the ping event.
If you do not see the location context then the OS/Browser is not allowing it.
I have allowed location when prompted by browser. And in settings , I have allowed location services. After using Snowplow Inspector, I do not see location context.
Search for location in windows settings, choose “location privacy settings” you’ll now see a specific menu page for this. Location shouldn’t be managed by your organisation (if it is the text will be yellow warning you of such), you’ll want location to be switched on and that Apps can access your location, you’ll also want to scroll down further and ensure Chrome can access your location (“choose which apps can access your precise location”). Make any changes and reboot the machine, test it in Chrome and ensure there are no icons with red in the right of the address bar in Chrome.
Click on the search bar, then click use my location, Chrome should pop up a notification for you to accept, if this does not happen then your machine is blocking it.