When you are about to migrate a site from CMS 11 to CMS 12, it's not unusual to want to do some rewriting and re-implementation to clean up the architecture as part of the project. When you do that (and in many other cases) it can be incredibly helpful to have a handy overview of your content, it's usage and your visitor groups and their usage. Here is an easy way to get that.
A long time ago, I made a simple Scheduled Job, called the Content Report Generator and shared the code for it here on this blog. It was quick and dirty code with a terrible architecture - and not that easy to expand. However, it solved a real problem: provide a way to get an overview of all your content in a way where you can work with it.
It did this by simply creating an excel file with a list of your content + some very valuable collected meta-information - like where it was used and who was supposed to approve it. Usually I'm no fan of excel - but it's a format that everybody usually can read - and it's even pretty easy to do filtering, grouping, sorting and similar actions - so it's pretty perfect for this purpose.
Recently, I've been working on a couple of really complex site-rewrites onto CMS 12 - and it has come in very useful to be able to extract similar reports - however I've started to notice an extensive use of Visitor Groups in many sites - as well as a common architecture where pages have a main content area and the actual content is in blocks - or even in blocks in blocks. This makes it increasingly difficult to spot which blocks and visitors groups are used on which urls.
So - I've rewritten and extended the old scheduled job. First of all, to get the code up to a somewhat better quality, making it more modularized so it's easy to add more data sheets - but also to support data about visitor groups, criteria and their use on the site.
To achieve this I used similar code to that of the helper methods I recently shared, Optimizely CMS: List content recursively on a page - and list the visitor groups used, and a bit of other magic.
The job still creates a content report and puts it in a folder in your sites assets ("Internal Reports") ready for download.
Here is an example of an output report from my test-alloy site (so not terribly interesting) - however I'm sure you can imagine what you might get out of this on your own site: Report 2022-05-20 13_57.xlsx.
It currently contains 3 sheets:
- Content Details. The list of content items (1 per ID+language) and essential meta-data. But also a list of where it's used, how many versions exist, who it's waiting on for review, and a list of which visitor groups it's using.
- Visitor Group Details. A list of each visitor group's criteria - and all the details regarding both the visitor group and the usage of that criteria. Could be used to spot duplicates or find out which groups are using which criteria.
- Visitor Group Usage. A list of where the visitor groups are used on the site. If a visitor group is used in a block, then it will both be listed for the block, but also for all the pages that block is used on.
The code for doing this in CMS 11 is below (and who knows - I might eventually make a package out of it) - but it shouldn't be hard to customize it and use it in CMS 12 as well.
I obviously quickly realized that it's even more fun to have this in PowerBI than 'just' Excel - and even though this format already supports some pretty nice PowerBI views, I think it could be even more fun to add more sheets and normalized data, where relationships can be set up in PowerBI. So hopefully I'll soon find time to do that as well - and maybe there'll be yet another blog post in this series...