GROQ-Powered Webhooks – Intro to Projections
A thorough intro to using GROQ-projections in a webhook contest
Go to GROQ-Powered Webhooks – Intro to ProjectionsThinking about your audience as one group is a handy way get things done. But people’s needs change based on who they are, where they are, and what they’re really after.
This guide will show you how to tailor your content to meet the needs of different people. With personalized and localized content you can deliver better experiences across a wider range of cultures, languages, and tastes.
Personalization is when you send different content to your audience based on what you know about them. Depending on what you do, the knowledge you use can be from a variety of sources including:
Only use data your audience has consented to share, or information that you can reasonably assume about them without harming their right to privacy.
How you personalize content for them is just as flexible. Here are a few ideas:
Be mindful of assuming too much about somebody without having the data you need to support your assumptions. Sending the wrong personalized message to the wrong recipient may do more harm than good. If in doubt, apply the precautionary principle, and use something fit for all.
Localization is simply a form of personalization that focuses on content targeted towards your audience‘s location. You may have encountered localized content on a website, where applying a region or language preference lets you use the site in a way that makes the most sense for where you are.
While language translations are really common, localization can be much more than that. Great localization experiences can tailor news feeds, images, currencies, shipping settings, and much more in order to make the customer experience as relevant as it can be.
CandiCorp’s subscription pilot is only being trialed in the EU‘s Nordic states. To avoid disappointing customers from other regions, they restrict the promotion of the program to website visitors and catalog recipients from these countries only.
Sanity lets you tailor content in a way that makes the most sense to you. You provide tailored content exactly the same way you do other fields or types in your content model. It’s possible to choose between field and document level localization, or a mix of the two. Be as simple or complex as you like.
This flexible, needs-based approach should outlast a preconfigured solution in the long-run and is a pathway to better content experiences because you can blend personalization and localization needs any way you like.
Tailored content can be as simple as adding new fields to your document, or an embedded object. Here‘s a Title field in English, Swedish, and Norwegian:
// schemas/documents/article.js
export default {
title: 'Article',
name: 'article',
type: 'document',
fields: [
{
title: 'Title',
name: 'localizedTitle',
type: 'object',
fields: [
{ title: 'English', name: 'en', type: 'string' },
{ title: 'Norwegian', name: 'no', type: 'string' },
{ title: 'Swedish', name: 'sw', type: 'string' },
]
},
// etc...
]
}
You can also apply customization at the document level. This basic example lets you set the language type when creating a new document:
// schemas/documents/article.js
export default {
title: 'Article',
name: 'article',
type: 'document',
fields: [
{
title: "Language",
type: "string",
name: "language",
options: {
list: [
{title: 'English', value: 'en'},
{title: 'Norwegian', value: 'no'},
{title: 'Swedish', value: 'se'},
]
}
},
// etc...
]
}
These examples are simple, but the principles are extendable to any use case.
We learned that it’s possible to create tailored content for audiences of all persuasions. We broke down the difference between personalization and localization and looked at ways to provide for both using Sanity. Next up, we’ll customize Sanity Studio for faster flows and better content.
A thorough intro to using GROQ-projections in a webhook contest
Go to GROQ-Powered Webhooks – Intro to ProjectionsA thorough intro to using GROQ-filters in a webhook-context
Go to GROQ-Powered Webhooks – Intro to FiltersA step-by-step guide to setup Next.js and Sanity Studio with Live Preview
Go to Live Preview with Next.js and Sanity.io: A Complete GuideHierarchies are handy for organizing, but they can also fence you in. Learn how to build them, when to use them, and why you might want to treat navigation as a separate concern.
Go to Hierarchies, Graphs, and Navigation