Step 4: How to Log Custom Metadata for Post Author and Category in Your Ghost Blog
Adding custom metadata to your posts can provide valuable insights into the performance of different authors and categories on your blog. In this tutorial, we’ll guide you through the process of modifying the post.hbs template to start logging custom metadata for post authors and categories using fullres.
Step-by-Step Guide
Step 1: Access Your Ghost Theme
- Log in to your Ghost admin panel.
 - Navigate to Settings > Theme.
 - Download your current theme by clicking the Download button next to the active theme.
 
Step 2: Modify the post.hbs Template
- Extract the downloaded theme and locate the 
post.hbsfile in your theme directory. - Open 
post.hbsin a text editor. 
Step 3: Add the Tracking Code
- Find the closing 
{{/post}}tag in thepost.hbsfile. - Add the following code snippet right before the closing 
{{/post}}tag to track the post author and category: 
<script>
  window.fullres ||= {events: [] };
  window.fullres.metadata.postCategory = '{{#if primary_tag}}{{primary_tag.slug}}{{else}}null{{/if}}';
  window.fullres.metadata.postAuthor = '{{#if primary_author}}{{primary_author.slug}}{{else}}null{{/if}}';
</script>
It should look something like this:

Step 4: Save and Upload the Modified Theme
- Save your changes to the 
post.hbsfile. - Re-zip the theme directory.
 - Go back to the Ghost admin panel, navigate to Settings > Theme, and upload the modified theme.
 - Activate the uploaded theme to apply your changes.
 
Step 5: Verify the Implementation
- Open a blog post on your site and check the page source to verify that the 
window.fullres.metadata.postCategoryandwindow.fullres.metadata.postAuthorvalues are being set correctly based on the post’s category and author. - Use the browser console to inspect the 
window.fullresobject and ensure that thepostCategoryandpostAuthorvalues are being logged as expected. 
By following these steps, you can start logging custom metadata for post authors and categories, giving you deeper insights into your content performance. This can help you make data-driven decisions to optimize your blog’s content strategy.

Up Next: Tracking Email Subscription Confirmations and Subscribe Button Clicks in Ghost