An Introduction to Web Analytics
Tags: analytics, webdev, codenewbie
Published: 2020-11-24 14:46:00

If you’re a developer running your own site, or you have a blog hosted on a blogging platform, you’re probably aware of web analytics. Content publishers rely on web analytics to understand how audiences are engaging with their content and to spot trends or patterns that will help them improve baseline metrics. For the purposes of this post, we’ll define web analytics and metrics as follows:

- **Web (or site) analytics**: the collection, analysis, and reporting of data compiled from a website for the purpose of research and optimization. 

- **Metrics**: something that you want to measure, often (but not always) correlated with an action a user takes on the site or a page. Well known metrics include “page views”, “unique visits”, and “click-through rate”. While the definitions of these metrics are more or less the same across web analytics tools and services, the way they’re calculated depends on the platform in question.

If you’re unsure about what web analytics are or what metrics you should pay attention to, this post is for you. Resources for additional reading will be available at the end of this post.

## Use Questions to Guide How You Look at Web Analytics

What makes web analytics useful is its ability to help you optimize your site and content strategy. Without these questions, analytics are an otherwise nice-to-have feature that you might not use. Analytics are only as reliable as the questions you ask and taking action based on your findings.

I only care about the data in aggregate, meaning, I look at what my total visitors do, not what an individual user did or did not do. I don’t run ads, I don’t retarget users on different platforms, and I don’t personalize my site content. I segment users in my email marketing platform in order to send relevant newsletters to specific subscribers and to archive inactive subscribers.

Here are some questions I look to my web analytics to answer:

- What keywords are people using to find my content in organic search?
- How do people find my blog?
- After reading a post, where on my site do people go to next?
- What are the biggest entry points on my site?
- What types of content perform the best?
- Which pages are underperforming?
- How many people are opening my newsletters?
- Which links in my newsletters receive the most clicks?
- Are there trends or patterns among these links that I should be aware of?

Start crafting questions or problem statements to help you maximize the value of your web analytics. 


## What Web Analytics Can & Can’t Tell You

As a content creator, web analytics is a tool that will help you gauge how well your content is performing. Web analytics can tell you what users do when they land on your post, what they do next, and how they get there. You can use this information to optimize your content calendar for high-performing topics, or to improve your search engine optimization strategy if you notice you get little traffic coming from search engines. 

Web analytics cannot tell you why a user took a certain path, why a bounce rate is so high, or why a blog post performed lower than expected. You can infer by looking at the data over time and identify patterns of behavior, by formulating a hypothesis based on what you see and running an experiment (A/B test), or by conducting user research like usability testing and user interviews.

Also – different platforms may only analyze a portion of the available data, especially if you’re using it for free (Google Analytics does this for sites using its free version) or paying for a premium service but by tier (Matomo Analytics prices its plans according to a monthly visitor cap). Blogging platforms that have their own native web analytics may give you only a limited set of metrics to look at; for example, Hashnode and DEV Community will show you total pageviews, number of comments, and number of “reactions”, i.e. likes, but that’s it. 

Cookies (otherwise known as HTML cookies or site cookies) impact the data your analytics tools are able to collect. If you use persistent cookies, you may be required to display a cookie banner on your site (there are exceptions; look at your web analytics provider for more details). Also, blogs hosted on platforms like Hashnode and DEV Community are governed by the platform’s cookie compliance policies). Users may have “do not track” settings enabled, and whenever a user clears their cache, they’re treated as a unique visitor the next time they visit your site. These aren’t things to lose sleep over but important to keep in mind.


## Types of Metrics and User Data

Web analytics tools also calculate metrics. Here are some common metrics by analytics tool (this is not an exhaustive list):

**Web analytics metrics**:

- Total & unique visits 
- Total & unique page views
- New vs returning visitors
- Traffic sources
- Bounce rate 
- Exit rate
- Click-through rate
- Time on page

**Social media analytics metrics**:

- Total number of impressions
- Number of likes
- Number of comments
- Number of retweets/reposts

**Email marketing metrics**:

- Total number of recipients
- Number of opens
- Open rate 
- Number of clicks
- Click-through rate

You can also add your own metrics to these platforms; many companies have metrics that correspond with different funnels and will make sure their analytics includes all the metrics they need to track.

How about user data? If you’re using a robust analytics platform, you’ll be able to view the following user data:

- Referral sources: the places where users come from and drive traffic to your site
- Device type
- Operating system
- Country: where users are located 
- Region
- Browser language


This data might be way more than you need at this point. But this type of data forms the basis of segmentation. Segmentation is the grouping of audiences by specific characteristics. If you want to run A/B tests for specific subsets of users, or if you want to focus on improving your site’s UX for certain device types, this type of data will help you target the right users

## How Web Analytics Platforms Get Data

In general, most web analytics platforms will require you to embed a tracking code (usually JavaScript) to your site’s header or footer. The code will execute on each page on the site. This lets your web analytics capture “events” on each page, or actions your users do like clicking a link, a page, the time they spend on a page, and so forth. Your web analytics platform logs the data and will often display data as visualizations in a dashboard. Most platforms have default dashboards but you can also create custom dashboards and reports from within your tool. 

Furthermore, web analytics platforms drop cookies in a user’s browser to track them on the site during their current visit (these are called “session” cookies) or to remember them in subsequent visits and/or track their movements beyond the site for advertising purposes (these are called “persistent” cookies). Analytics uses session vs persistent cookies to differentiate between total visits and unique visits, which count only the first time you visited the site. Note: cookies don't track users across devices, so the same user accessing the same page on both their mobile phone and their laptop would count as two unique visits.

## Other Uses of Web Analytics

Because of the mechanisms used to collect data, web analytics platforms also power the following types of activities:

- **Retargeting**. If you’ve seen an ad on a news website for a product you shopped for on a different site, this is retargeting in action. 

- **A/B testing**. Online experiments, or A/B tests, work by serving up a variation of a page that has had a small change made to it. Visitors are randomly assigned to either the “control” group or the “treatment” group; the control group sees the existing experience and the treatment sees the change. On the backend, the analytics platform measures any changes to key metrics on the page and uses statistics to determine which version is the winner.

- **Personalization**. Personalization works by serving a different version of a page to a group, or “segment” of users, based on shared characteristics. These segments are built based on the activity previous site visitors have done and will “serve” them an experience based on which segment they fall into.

These activities may require a separate system to run, but they use web analytics as their data source.

## Which Web Analytics Tool to Use

Google Analytics by far is the most popular web analytics platform for everything from personal sites to large, enterprise sites. It’s free to use, but with everything, there’s a catch: GA will only analyze a portion of your data, and user data is sent to and hosted on Google servers. If this is an issue, consider other analytics tools. When looking for an analytics platform, I was looking for one that was robust, that didn’t share data with third parties, and that was privacy-minded. Here are some platforms that are similar (some are even open source):

- Matomo Analytics
- Fathom Analytics
- Simple Analytics
- Plausible Analytics

Note that there’s nothing wrong with only having access to a slice of your metrics and data. For some people, platforms like Matomo and Google Analytics are too rich and tell them more about their users than they need or want to know. As long as you understand what metrics are valuable to you and what you can and can’t infer from these metrics, use the platform that is right for your use case.

I would recommend reading up on all of these options (and there are many more) to find the one that meets your needs. 

## Conclusion

Web analytics tools work by collecting data on the actions users take on your site in order to improve your site’s usability, content, or to create personalized experiences. To use them for data-driven decision-making, craft questions that align with your metrics and look at your analytics regularly to spot changes in metrics. Finally, research the differences between analytics tools to identify the best one for you.

### Resources
- https://www.usability.gov/what-and-why/web-analytics.html
- https://plausible.io/vs-google-analytics
- https://matomo.org/blog/2020/02/web-analytics-cookies-gdpr/ 
- https://www.bounteous.com/insights/2019/12/23/how-google-analytics-uses-cookies-identify-users/ 

[_This post originally appeared on my blog._](https://www.stephaniemorillo.co/post/an-introduction-to-web-analytics)

_I'm Stephanie, a Content Strategist and Technical PM. Visit [developersguidetocontent.com](https://www.developersguidetocontent.com) to learn more about my work!_