How Do I Set Up Google Analytics GA4 to Track Page Views by Blog Category Using a Custom Variable Macro in SoCast?
Overview
This guide explains how to set up Google Analytics GA4 to track page view events by blog category using the custom variable macro %socast.blog.categories%
. This process involves adding the GA4 tracking code with the custom variable macro to your SoCast website and configuring Google Analytics to report on page views by blog category.
Step-by-Step Instructions
1. Insert GA4 Tracking Code in SoCast
-
Log in to SoCast:
- Go to the SoCast platform and log in with your credentials.
-
Access Website Settings:
- Navigate to Website > Website Settings.
-
Locate Custom Footer HTML:
- Find the "Custom Footer HTML" section.
-
Insert GA4 Tracking Code with Custom Variable Macro:
- Copy and paste the following code snippet into the "Custom Footer HTML" section. Replace
G-XXXXXXX
with your GA4 Measurement ID.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXX', {
'custom_map': {'dimension1': 'blog_category'}
});
// Capture the blog category
gtag('event', 'page_view', {
'blog_category': '%socast.blog.categories%'
});
</script>
2. Verify Implementation
-
Publish and Access a Blog Page:
- Publish your changes and open a blog page on your website.
-
Use Google Tag Assistant:
- Install the Google Tag Assistant Chrome extension to confirm the GA4 tag is firing and the
blog_category
parameter is being captured.
3. Set Up a Custom Dimension in GA4
-
Log in to Google Analytics:
- Access your GA4 property by logging in to Google Analytics.
-
Navigate to Admin Settings:
- In the bottom left corner, click Admin.
-
Set Up Custom Dimensions:
- Under the Property column, click Custom Definitions.
- Click Create Custom Dimensions.
- Fill in the following details:
- Dimension name: Blog Category
- Scope: Event
- Description: Tracking blog category names
- Event parameter: blog_category
- Click Save.
4. Create a Report in GA4
-
Go to Explore:
- From the left-hand menu, select Explore.
-
Create a New Exploration:
- Click Blank to start a new exploration.
-
Set Up the Exploration Report:
- Rename your exploration if desired (e.g., "Blog Category Page Views").
-
Add Dimensions and Metrics:
- Click the + icon next to Dimensions and select Blog Category.
- Click the + icon next to Metrics and select Event Count.
-
Configure the Table:
- Drag the Blog Category dimension to the Rows section.
- Drag the Event Count metric to the Values section.
-
Apply Filters (Optional):
- If needed, use the Filters section to add relevant filters.
-
Save and Analyze:
- Save your exploration and analyze page views by blog category.
By following these steps, you can successfully set up Google Analytics GA4 to track page views by blog category using the %socast.blog.categories%
macro. This setup allows you to create detailed reports in GA4, providing valuable insights into the performance and engagement of different blog topics. Use this data to inform your content strategy and optimize your website for your audience.
Related Articles
How Do I Set Up a Custom Google Analytics Blog Category Report?
This Article Is For: Advanced users/company admins Website Settings Permission is needed These instructions assume you've already created a Google Analytics account for your website. If you haven't done this yet, go here: ...
How Do I Add Google Analytics to My SoCast Website?
How Do I Add Google Analytics to My SoCast Website? Note: If you are using the SoCast player, you will also need to add your Google Analytics tracking code to your player settings. For detailed instructions, please see our article: Adding Google ...
Why Is There a Difference Between Blog View Counters and Google Analytics Traffic Data?
Why Is There a Difference Between Blog View Counters and Google Analytics Traffic Data? Radio broadcasters often notice discrepancies between the blog view counter on their website and the numbers reported by Google Analytics. Understanding these ...
How Do I Use the Page Analytics (by Google) Chrome Extension for Google Analytics?
How Do I Use the Page Analytics (by Google) Chrome Extension for Google Analytics? Who Is This Article For? Users with access to a Google Analytics (GA) account. Notes For more information on the Page Analytics Chrome Extension, visit: Google ...
How Do I Read the Omnichannel Engagement Report in SoCast Analytics?
How Do I Read the Omnichannel Engagement Report in SoCast Analytics? The Omnichannel Engagement Report provides a comprehensive overview of your station’s digital performance across web, mobile app, player, blog, social, and contest channels. Below, ...