Add geolocation-based redirector view class and documentation
We typically do geolocation on bedrock on the client side by requesting the user's country code at our country-code.json endpoint. This works by parsing the information out of the request headers, as our CDN has already used IP-based geolocation to gather that info and has sent it to us.
Another use of that header for us could be to create a URL (or convert an existing URL) that is purely a redirector (i.e. it only returns 302 responses) that looks at the country code and then sends the user to one of potentially several URLs based on the country. This needs to be a simple redirector view because it has to be uncached by the CDN and so all traffic to the URL will hit bedrock, and so we don't want to spend time rendering templates or hitting the database. We simply lookup the proper URL and return a redirect response, and then we let the normal caching happen at the resulting final destination URL.
This might be the desired way to handle geolocation since it keeps the front-end code more simple (no async requests), it makes the UX better and less complex (no content swapping), and potentially makes the page feel faster (time from first paint to last should in theory be shorter).
This issue is to document how this might most easily be done and to add helper classes to make this easy. It should work something like this in the end:
# views.py
class FirefoxGeoView(GeolocationView):
geolocation = {
'de': 'firefox.germany',
'fr': 'firefox.france',
'default': 'firefox.index',
}
That view would then redirect users with "de" country code to the view with the name firefox.germany for example.
From a technical point of view I think this sounds great, and would simplify many things we currently have to do client-side. One area where we may have to give a little further thought could be SEO however, so I would love to get @rraue's thoughts on this?
I can imaging something like the above would work great for non-indexable URL's, such as /whatsnew/. For public URLs (such as Firefox download pages) I'm not so sure though, since we could end up with multiple URL's all competing for the same search terms. For example with the recent Yandex page, we initially discussed using entirely separate URL's / templates which would have been much easier, but decided against it for the following reasons:
- Two competing pages / URLs would have confused Yandex's search engine for ranking (similar to the confusion we currently have with
/firefox/and/firefox/new/). - People outside of Russia could have ended up seeing the Yandex promo if the URL made its way into the search index (this could have been very bad in the Ulkraine, for example).
I wonder if there is anything we could do here to make search engines better understand the intent of country-specific pages like this? If not, then perhaps we should have some SEO specific documentation as to how we should use a tool like this.
Absolutely. I've pinged Raphael in a doc about this, but discussing here seems more appropriate. We'll definitely need to weigh that should we want to use this technique on an already well-established URL.
I still did not completely understand the change but basically what needs to be true for SEO:
- Links have always one destination (we have some exceptions like for releasenotes and that's fine but they need to be exceptions)
- Every language/country needs its defined url, so there has to be a complete mapping possible for hreflang
- It is no problem if these urls have different patterns (/klar & /focus) if it is clear in hreflang which url stands for which language/country and they are referenced accordingly
- If a user or crawler hits a specific language/country we must not redirect, as 98% of all google crawls come from the US and we would lose then all locales
From a UX perspective we need to think about users living in two or more language countries (canada or swiss for example) and users abroad, so I think language is still more important than geo location, but it could be combined: geo only if no extra language is set
I think language is still more important than geo location, but it could be combined: geo only if no extra language is set
Agreed. But we have run into situations where location matters more than language. We're seeing that with Firefox Rocket, which is only available in certain countries in the app stores, and Firefox Focus/Klar which has a different name and legally can't be called the other name in certain countries regardless of language. Hopefully the use of this will be rare and appropriate, but having good SEO information will help us argue for the proper solution in these situations.
@pmac @rraue
Take Firefox Lite (Android) for example, it's limited to certain countries, because it's designed with specific needs for some Asia countries. If users in other countries goes to the Google Play page, they will see error page, or not being able to download Firefox Lite.
So we can't find a place to talk about Firefox Lite in India right now, because 99% of India traffic goes to en-US and en-GB, the usage of the 4 available Indian languages of mozilla.org only serve less then 1% of users.
It would be great if we can have pages like: https://www.mozilla.org/en-IN/firefox/mobile/ https://www.mozilla.org/en-IN/firefox/whatsnew/ to promote Firefox Lite.
@peiying2 thoughts on the above? I've often thought that en-IN would be a good one to support, but I'm not sure if it's something the l10n community would support.
@elin-moco even if we did get en-IN however that wouldn't guarantee that it was people viewing the page in India, so I think we'd still need geolocation like we're discussing in this issue.
@pmac @peiying2 the en-IN en-ID pages will only be needed for mobile product promotions in Asia for now, for example: /en-IN/firefox/mobile/ /en-IN/firefox/whatsnew/ the content will be different from en-US, promoting Firefox Lite instead of Firefox for Android. Just like this: https://www.mozilla.org/id/firefox/whatsnew/ We will work with copy writer to create English copies for these, and localization agency for Indonesian copy. Which means it doesn't require l10n community support for this.
For geolocation detection, yes, so maybe these URLs need to detect geolocation and redirect to corresponding country pages: https://www.mozilla.org/firefox/mobile/ https://www.mozilla.org/firefox/whatsnew/ Also may need to consider which URL does Firefox Desktop drive users to, because traffic of what's new page mostly comes from Firefox desktop, it would be great if it can just send users to en-ID/en-IN what's new pages.
Although /en-US/firefox/mobile/ /en-IN/firefox/mobile/ maybe competing for similar keywords, they will represent different products (Firefox for Android for en-US, Firefox Lite for en-IN/en-ID) Maybe consider merge en-IN/en-ID into en-II for better SEO, since these 2 pages would be exactly the same.
I think we're getting into the weeds a bit here with implementation details. We just need to know what you'd like and who should see it. There are a lot of ways we could show location-specific content in English to people in certain countries. The en-IN locale is not currently enabled on the site, so probably the best way forward for now is something more like /en-US/firefox/whatsntew/?country=IN or /en-US/firefox/whatsnew-in/.
This issue is getting long and is more on a more general topic than these specific pages, so let's open a new issue just for country-specific whatsnew or move back to the bug. Either way is fine with me.
Pardon me for getting into those details, probably a bit misleading.
What we need currently is, for users in Indonesia/India (may open up to a few more countries in the future), they see product page and what's new page for Firefox Lite by default. (instead of seeing the en-US product page/what's new page for Firefox Android) It would be great if Firefox Lite product page can appear on top of their Google search result.
Back from PTO and a bit late to the party but here are my 2 cents without considering scope:
- All client side changed urls or content is potentially not seen by search engines or misinterpreted. For SEO a server side solution is allways preferred.
- Not indexed pages like whatsnew or firstrun can be handledhow so ever
- Users will hear in other parts then asia about firefox lite or rocket as well, so I would build a english landing page anyways, and alter client side what information (download, not downloadable in you country + reason) the page shows plus the standard content about what is lite, how is it different to normal firefox etc.
- If we market in differnet areas different (en-IN) having this locale is always the best solution. But I wouldnt alter /mobile/ but build /mobile/lite/ and /mobile/rocket/ for all locales with differnet content (available - not available for reasons)
Sounds great!
@pmac, do you have bandwidth to take this on in the next 3 weeks? We'll need it if we're to deliver on https://github.com/mozilla/bedrock/issues/7552 by 70.
Yes. I should be able to have this facility ready.