Javascript tracker not sending geolocation data

Hi

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>

Hi @achintya.c

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:

  1. On your computer, open Chrome .
  2. At the top right, click More. Settings.
  3. Click Privacy and security. Site Settings.
  4. Click Location.
  5. Choose the option you want as your default setting.

Kyle

1 Like

I will try and let you know.

Many thanks

1 Like

Hi

I followed your steps and allowed the prompt for tracking location in browser but geolocation data did not reached through to Postgre DB.

Does the geolocation context show up in the Snowplow Inspector?

If you’re expecting the atomic geo_* fields to be populated in your DB, then they are populated by the IP Lookup Enrichment.

The Geo Context in the tracker adds an Entity to your events as Mike describes, but it doesn’t populate the geo_* fields.

1 Like

Thanks for your reply Paul.

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.

Thanks again.

I believe you’ll need to restart the enrich servers you’re running.

Hi

We have restarted the enrich server after the changes, but the geo_* fields remains null.

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.

1 Like

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.

Not sure why so?

If you do not see this then your Browser and/or Operating system is blocking the location call.

(I’ve covered my cords as its very accurate)

No I don’t see the the information , you shared on screen. Any idea why they are not visible?

What is your Operating system and what browser are you using?

1 Like

I am on Windows 10 and Google Chrome Version 98.0.4758.82 (Official Build) (64-bit)

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.

Go here

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.

All going well, then test with Snowplow.

2 Likes

Thanks for your reply. I will surely go through it.