amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

AMP_GEO(ISOCountry) value does not update despite change in user location

Open gswetha opened this issue 7 years ago • 4 comments

What's the issue?

AMP_GEO(ISOCountry) value does not update despite change in user location. How is its value stored for subsequent requests?

I'm using amp-geo in 2 ways:

  1. <amp-pixel src="https://foo.com/pixel?country=AMP_GEO(ISOCountry)"></amp-pixel>
  2. <amp-list src="deals.json?country=AMP_GEO(ISOCountry)" >

How do we reproduce the issue?

https://gist.github.com/gswetha/edefd68fe4c1c662648b2e0b875e6384

  1. Open URL in mobile emulator and record value of AMP_GEO(ISOCountry)
  2. Use VPN to simulate a different country
  3. Refresh page and record value again. It shows the same value although I am simulating a different location
  4. This happens in both normal and incognito mode
  5. The scenario when the value updates is when I record value in incognito --> use VPN to simulate different country --> close incognito window --> reopen URL in incognito

Imagine a use case where we have a frequent traveler using a flight booking widget with amp-geo showing country specific deals. If the user opens the URL location A and sees deals for location A --> doesn't book --> travels to location B --> still sees deals from location A, that would be bad UX.

Hence, I'm trying to understand why the value of AMP_GEO(ISOCountry) doesn't change and how it is being cached.

What browsers are affected?

All. I simulated with Chrome, Firefox and Safari

Which AMP version is affected?

Version 1812131718380

gswetha avatar Dec 17 '18 10:12 gswetha

The country code is burned into the amp-geo js file when it is served based on the geographic origin of the request. It has a 30 minute cache max-age. If you are testing by jumping from country to country using a VPN and it's not working there are two likely issues.

  1. You didn't clear the cache between tests.
  2. The VPN endpoint is not recognized as being in the country you think it's in.

jpettitt avatar Dec 17 '18 18:12 jpettitt

Thanks for the prompt reply! The VPN endpoint should be recognized since the AMP_GEO(ISOCountry) value changes after manually clearing cache/close and reopen incognito window.

I tried to test the 30min max-age by open URL and record request --> after 1.5hrs --> simulate another country --> reload URL. However, the max-age doesn't have any impact as the location value still doesn't change. It only changes when I manually clear the browser cache.

This would not be representative of user behavior as they usually don't clear cache.

gswetha avatar Dec 18 '18 07:12 gswetha

~That sounds like the amp-geo file is being cached for longer than it should. Which browser version and can you post the full http headers you are seeing? (in particular the cache and encoding headers)~

Scratch that, the headers you sent indicate you are on an internal corporate network. The VPN is not going to override that. Connect to a regular non-corp WiFi and try it - it should work there (it just did for me)

jpettitt avatar Dec 18 '18 15:12 jpettitt

Thanks John, I’ll go ahead and close this issue due to some VPN pitfalls with the test on both mobile device and emulator.

It would be great to see a testing guide for amp-geo in the official documentation!

gswetha avatar Dec 19 '18 02:12 gswetha