Proposal: option to provide a static url->title mapping for the "Page titles" report #234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I want to use Matomo to track visits on my site, and I decided to use only log analytics. I'm aware of the limitations, that some things will be missing compared to JS tracking - like resolution info, outgoing links, plugin support etc., and I'm fine with that.
However, I've realized that on a relatively rarely changing site like mine - a blog with a few articles posted per year at most - I can solve one of these things, namely the "Page titles" which are normally read in JS from the
<title>
tag, by providing a static list of url -> title mappings in a file passed in a parameter to the import script.The file looks like this (the first
=
is treated as a separator and both sides are trimmed from whitespace, but of course we can change the format to e.g. CSV or something else):Now, when I call
import_logs.py
with--page-titles-from=page_titles.txt
, whenever the parser sees a hit with URL e.g.https://mackuba.eu/2018/07/10/dark-side-mac-2/
, it will set theaction_name
to"Dark Side of the Mac: Updating Your App – mackuba.eu"
, and so on. My "Page titles" report looks just like with the JS tracker version, and I only need to remember to update the file whenever I post a new article (or better, automate it).I believe quite a lot of sites using log analytics could use something like this. Depending on the size and type of the site the file can be maintained manually, or built from a database of articles/pages using a script or an action on the server. In my case, I wrote a small script that loads my
sitemap.xml
file and then goes through all link items listed there, fetches each HTML and extracts the<title>
from it.