Pricing update: Free users
NEWS · December 16th 2019

Better ContentOps with Google Analytics right inside the Sanity Studio

Get the numbers where you're working. Up your ContentOps game with Google Analytics right inside the Sanity Studio.

Even Eidsten Westvang

Even is a co-founder

Knut Melvær

Knut runs developer relations at

Content performance data is seldom available where decisions are made about content. With the new version of Structure Builder and the split panes functionality, it’s possible to insert React components right where your documents are edited. This opens up a vista of possibilities, one of them: bringing in statistics and charts from Google Analytics. In this post, we’ll show you how to set this up, but also argue that doing so might make a lot of strategic sense for how you do content operations.

It can be easy to think that taking care of a website is mostly about adding new content to it. This isn't true though. Crafting great websites is kind of like the art of bonsai. Often your time is better spent refining what you have or throwing out stuff that doesn't work at all.

As the customer experience expert Gerry McGovern points out: «Whether it’s with Norwegian telecom company, Telenor, Microsoft Excel, or the Liverpool council website, we usually find that deleting 80% of the content leads to much better results.»

Putting in place routines that allow you to work on what matters is what content operations is all about. But the reports that inform your decisions aren't accessible where your content is, and it can be hard to cross-reference timelines.

You now have the right information available right inside the editing interface along with publishing timestamps. Have you been lowering that bounce rate on that landing page this last month? Now you know.

Chart showing bounce rates with publishing marks

What is Content Operations?

Content Operations, or ContentOps, are the practices you put in place to make sure that your text, images, and other media meet some measure of quality. Your Content Strategy is made up of the decisions you make on how your content is created and distributed to meet certain goals. ContentOps is how you “keep stock” of your content, making sure it stays up to date, that outdated content is removed, that content is re-organized according to new requirements, and that there’s quality assurance when new content is created.

When you have introduced structured content in your organization, you have also made it easier to implement great ContentOps, and with Sanity Studio, you can give your editors customized workflows to exactly match whatever their criteria may be

The challenge with web statistics

It’s not uncommon to install Google Analytics on a site and forget that it exists. Even weekly reports and dashboards don’t ensure that the ContentOps decisions are raised when they need to. This is a problem of context. Like the speed gauge in your car (your non-self-driving car, that is), you need the numbers when you’re making the decisions. And you don’t need all of the numbers, you need just the right ones. Now that's easier to do.

Presenting the Google Analytics Plugin for the Sanity Studio

What a dashboard for would have looked like 3 years ago

With the new Google Analytics plugin for the Sanity Studio you can now embed different charts and statistics in Dashboard widgets, and document views. We also included a Higher Order Component that lets you integrate data from Google Analytics inside your own custom components. This is handy for when you want to use your own charts library, or want to connect functionality to the data.

Embedding Google Analytics charts in document forms

If you are familiar with the Google Analytics queries, often used in spreadsheet integrations and similar, you already know how to configure most of the functionality in this plugin. Additionally, you can override the onSelect handler to link directly to the content inside of the Sanity Studio from summary tables. For example, you can have a list of your top bouncing pages on the Dashboard, and click the titles to go directly to where you can edit the content. Setting up this plugin also makes for excellent opportunities for developers, growth marketers, designers, and editors to think about how the content is structured and what one can measure to make better decisions.

Overlaying publish events

Since Split Panes also gives you an easy path to getting the values for the document history, it's possible to overlay publish events on charts. This is another to interrelate content with data in order to inspire better questions about how content strategy: Why do we see no difference in goal conversion before and after the rewrite? Or, why did the search referral traffic go significantly up after we let our new editor rework our marketing copy?

Overlay publish events

Better ContentOps with great customization

The Google Analytics plugin is to us another example of why customization is essential for how to work with content in any team. Even with best practices, no organization works the same way, or have the exact same set of challenges or people to tackle them. That's why when we ask people what they would use if Sanity didn't exist, most of them say that they would have to build something themselves.

We didn't change any core functionality of the Studio to make this plugin, it uses the same public APIs that you have access to. And that shows the strength of having the CMS being open-source and built in a popular front-end framework for customization. The truth is, we needed this Google Analytics plugin for our own work, so we built it, so it made sense to share it with you as well.

We can't wait to see what you do with it!

Go to the Google Analytics plugin page