How We Track WordPress Authors in Google Analytics 4 (GA4)

At Martech Zone, we have a talented group of contributors whose work spans marketing technology, analytics, and innovation. Understanding which authors drive the most engagement, traffic, and conversions helps us continually refine our editorial strategy.
While Google Analytics 4 (GA4) doesn’t include an “author” dimension by default, we’ve implemented a simple and effective way to track authors within our WordPress site. By sending the author name as a custom parameter to GA4, we can easily measure performance by writer in both standard reports and Looker Studio dashboards.
Why Tracking Authors Matters
Running a multi-author publication means content quality and audience engagement can vary significantly between contributors. Tracking by author allows us to see which topics, tones, and writing styles resonate best with our readers. It also helps us identify areas for improvement and reward writers whose work delivers the strongest performance. With GA4 author tracking in place, our editorial decisions are guided by data rather than assumptions.
When we evaluate traffic and conversions by author, we can answer meaningful questions:
- Which authors consistently attract the largest audiences?
- Whose articles generate the most repeat visits or time on page?
- Who’s writing the content that drives newsletter signups or leads?
These insights strengthen our ability to allocate effort where it delivers the highest return.
How GA4 Handles Custom Dimensions
GA4 allows us to extend its data model through event parameters and custom dimensions. Each time a page view is recorded, additional details (such as the author’s name) can be passed along. Once that data is registered as a custom dimension, it becomes available in reports, explorations, and Looker Studio.
We use this to send a page_author parameter on every post. After registering that parameter in GA4, we can filter and compare performance across our contributors with a single dimension.
The Simplest Solution: A Custom Plugin
Rather than modifying theme templates or relying on a bulky analytics plugin, we developed a lightweight WordPress plugin that automatically passes author data to GA4 whenever a post is viewed. It works with any theme and requires only one minor customization… adding your own GA4 Measurement ID.
Plugin: Track Authors in GA4
File: track-authors-in-ga4.php
<?php
/**
* Plugin Name: Track Authors in GA4
* Plugin URI: https://dknewmedia.com
* Description: Adds the post author name as a GA4 custom parameter for detailed content analytics, with a configurable GA4 Measurement ID.
* Version: 1.1.0
* Author: Douglas Karr
* Author URI: https://dknewmedia.com
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: track-authors-in-ga4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Track_Authors_In_GA4 {
private static $instance = null;
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
private function __construct() {
add_action( 'wp_head', [ $this, 'add_meta_tag' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_script' ] );
add_action( 'admin_init', [ $this, 'register_setting_field' ] );
add_action( 'admin_notices', [ $this, 'admin_notice_missing_id' ] );
}
/**
* Adds a meta tag with the post author name to single posts.
*/
public function add_meta_tag() {
if ( is_single() ) {
$author_name = get_the_author_meta( 'display_name' );
echo '<meta name="post_author" content="' . esc_attr( $author_name ) . '">' . "\n";
}
}
/**
* Enqueues the GA4 tracking script using the saved Measurement ID.
*/
public function enqueue_script() {
if ( is_admin() ) {
return;
}
$ga_id = get_option( 'track_authors_ga4_measurement_id', '' );
if ( empty( $ga_id ) ) {
return; // Don’t enqueue if ID isn’t set
}
wp_register_script(
'track-authors-in-ga4',
'',
[],
'1.1.0',
true
);
$script = <<<JS
document.addEventListener('DOMContentLoaded', function() {
const authorMeta = document.querySelector('meta[name="post_author"]');
const authorName = authorMeta ? authorMeta.content : 'unknown';
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{$ga_id}', { page_author: authorName });
});
JS;
wp_add_inline_script( 'track-authors-in-ga4', $script );
wp_enqueue_script( 'track-authors-in-ga4' );
}
/**
* Register the GA Measurement ID field in WordPress Settings > General.
*/
public function register_setting_field() {
register_setting(
'general',
'track_authors_ga4_measurement_id',
[
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'default' => ''
]
);
add_settings_field(
'track_authors_ga4_measurement_id',
'GA4 Measurement ID',
[ $this, 'render_setting_field' ],
'general',
'default'
);
}
/**
* Display the input field for the GA Measurement ID.
*/
public function render_setting_field() {
$value = esc_attr( get_option( 'track_authors_ga4_measurement_id', '' ) );
echo '<input type="text" id="track_authors_ga4_measurement_id" name="track_authors_ga4_measurement_id" value="' . $value . '" class="regular-text" placeholder="G-XXXXXXXXXX">';
echo '<p class="description">Enter your Google Analytics 4 Measurement ID (e.g., G-ABC1234567).</p>';
}
/**
* Warn admins if GA4 Measurement ID is missing.
*/
public function admin_notice_missing_id() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
if ( empty( get_option( 'track_authors_ga4_measurement_id', '' ) ) ) {
echo '<div class="notice notice-warning is-dismissible"><p><strong>Track Authors in GA4:</strong> Please enter your GA4 Measurement ID under <a href="' . esc_url( admin_url( 'options-general.php#track_authors_ga4_measurement_id' ) ) . '">Settings → General</a> to enable author tracking.</p></div>';
}
}
}
Track_Authors_In_GA4::get_instance(); How We Installed It
- Create a folder: /wp-content/plugins/track-authors-in-ga4/
- Save the file: Inside that folder as track-authors-in-ga4.php.
- Activate the plugin: In WordPress admin → Plugins → Installed Plugins → Activate.
- Enter your GA4 Measurement ID:
- Go to Settings → General.
- Scroll down to GA4 Measurement ID.
- Enter your ID (e.g., G-ABC1234567) and click Save Changes.
- Clear any cache: This will ensure the meta author tag is published.
- Verify the meta tag: Each of your single pages should have the author meta tag now.
<meta name="post_author" content="Douglas Karr"> Setting Up the Custom Dimension in GA4
To make GA4 recognize the author parameter, we added a new custom dimension:
- In GA4, go to Admin → Custom Definitions → Custom Dimensions → Create Custom Dimension.
- Name it Page Author.
- Set the scope to Event.
- Use page_author as the event parameter name.

Once saved, GA4 started collecting author data. Within 24 hours, we could filter reports by author name.
Verifying the Implementation
We verified the setup using GA4’s Realtime report. By viewing a live post and inspecting the event parameters, we saw page_author populated with the correct author name. That confirmed the parameter was being sent and logged successfully.
Analyzing Performance by Author
After a few days of data collection, we built a Free Form exploration in GA4. By adding Author as a dimension and metrics such as Views, Engaged Sessions, and Conversions, we can directly compare author performance.
This view quickly revealed which writers drew the most engaged traffic, whose posts led to conversions, and how topics aligned with audience behavior. We also linked GA4 to Looker Studio to visualize author performance over time.
What We Learned
This minor customization added a powerful new dimension to GA4, helping guide our editorial and marketing strategy. Tracking by author has become an integral part of how we evaluate our content’s impact and refine our publishing efforts. It’s a lightweight, transparent, and scalable analytics approach that any WordPress publication can adopt.


