Determine users country by ip

there is no way to retrieve output, that would be possible only through Blockspring

Yeah, but blockspring is being called from the server ?

Or is it … is it being called TWICE (as per the thread on random alphas) ? So are there really two IPs and can you get the “right” one ?

In fact I didn’t find such an option in Blockspring to simply catch the visitor’s IP. So i have followed Ali’s advise to use Mixpanel - it would show me which events happened broken down by the originating country.

3 Likes

Seems like the best way for now.

Hello @emmanuel

Can you support this topic by adding the code incorporated in the below url to determine user IP. The problem with the BlockSpring Block is that it always retrieves the server’s IP and not the user. But placing the below call retrieves the users IP that can be later used in conjunction with blockspring by adding it under IP Address. (This is a BB Block)

https://www.ipify.org/ - Free API available Here
Give it a try here https://api.ipify.org/ (No key requried)

i believe this will add value to the community as it is required to meet some legal aspects when users accept terms and conditions of the website. Also it can be used to determine time zones, or automatically redirect users to specific pages based on country

Would love for this to be incorporated in the core of Bubble so it can be used easily as dynamic data like other options e.g. Current location so it can be used in workflows…

Another subrequest is to determine timezone by extract of using the current date/time

3 Likes

I just added it (and also added a plugin to show the compliant cookie message for sites in the EU).

See the new plugins:

  • Cookie consent (EU)
  • ipify
3 Likes

@emmanuel thanks for great support

1 Like

Ali, did you try it? In my case it returns always the same result for country/state/city which is US
OR
Boardman
means that probably the ipify plugin doesn’t work correctly.
Please let me know

Works fine here.

Have look and test here

Or run it here
https://publictestapp.bubbleapps.io/version-test/ip?debug_mode=true

Take a look at the plugins also. You have to use the ipify plugin in the BB block

1 Like

Yes, that’s exactly how I implemented also, but the strange thing is this one:
In the debugger it shows the correct values. look:

but in the database it saves some default ones (same every time), and also when i send this values over email, it also sends the default ones
see here:

@georgeciobanu @emmanuel any clue?

Is this the same issue as the random number generator generating a front end and a back end number ?

So…Bubble does two calls to ipify … one on the “front end” that shows the browser IP. The back end does another call that it stores in the database which is the back end server IP adddress. Amazon has a cloud server in Boardman, Oregon ?

Like Schrodinger’s cat … as soon as you try to persist the IP address … it flips to the Server ? Maybe ?

(pure speculation of course).

I added a couple more text boxes to call the Country and Country iso.

I get the right IP and City (Valencia, Spain), but the wrong Country and Country iso… both show US. Any idea why??

You had something weird in the parameters …

You need to pass it the result of the API.

It works now. I get UK and GB on the page.

2 Likes

Excellent! Thank you!!

However … this is exactly the same issue as the Blockspring randomiser.

Click the “save it” button. You will see the “browser IP” appear quickly, then it will be overwritten by the servers copy.

Even if you go via a custom state, you can’t trick the back end :frowning:

Hi!
Could you please clarify if the message is displayed in English only or also in other languages? The privacy policy link should pass a language identifier in order to display the privacy policy in the appropriate language (browser or User options).
Apologies if the question might look stupid as I’m a newbie Bubbler :slight_smile:
Regards
Mario

ipify doesn’t exist anymore?

Certainly does:

1 Like

Works, Great man. I appreciate it from all of you!

Noted! :ok_hand: