Targeting a Sanity landing page by country, which signal do I match?
I want visitors from one country to see a different hero on one of our Sanity landing pages. What I am not sure about is which signal I match on, and whether this needs any geo code added on the site itself.
Can someone show me how I target the audience for a specific country? I am comfortable enough with a bit of technical setup, I just do not know the right expression to write.
2 answers
You do not need any geo code on the Sanity site. Location is resolved by Croct, so you just write the audience condition and it evaluates in real time per interaction.
For country level the expression is:
location's countryName is "us"You attach that audience to the experience serving your hero slot, then give that experience its own variant content. Visitors resolved to that country get the variant, everyone else falls through to your default Sanity content.
One reassuring detail: undefined variables evaluate to false by design, so a visitor whose location cannot be resolved simply does not match and gets the default. No error, no blank hero.
it matched on the first try, thank you. the no-geo-code part is what I was missing
If you later want to go narrower than a country, the same location object gives you region and city. So you can refine to something like:
location's stateCode is "ca"or down to a city with location's cityName is "San Francisco". Same idea, just a more specific condition on the same audience, no extra code on the site.