Script to Overwrite Topic Titles in HTML5 for Analytics?

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets

Script to Overwrite Topic Titles in HTML5 for Analytics?

Postby techwriter31 on Thu Aug 08, 2019 2:20 pm

To help with Google Analytics, we'd like to overwrite the default Topic Title that's defined in our generated HTML5 topics to use the following format:
[Product Line] - [Topic Title] - Documentation | [Company Name]

We use global project linking, of sorts, where we have a "global" project that contains assets (HTML5 master page, skin file, .css, global variable set, etc.) that are shared among all projects. However, instead of using the traditional Flare global import file, we use SVN externals to automatically push this content to all projects. We then use TeamCity to automatically generate our documentation. The builds are configured to support SVN externals, so any time I commit an update to the global content, it runs all the builds and these changes are immediately present in all outputs.

So I'm hoping to come up with a solution where I can make changes to our global content for this change, without requiring our writers to manually make any changes.

I did a little testing and updated the global master page to include the following script:
Code: Select all
            document.title = "[%=Global/Global.Title%] - [%=System.Title%] - Documentation | Company";

This is nice because I can use a Global.Title variable that's already defined in our projects for our HTML5 footers. It overwrites the text displayed in the browser tab and if a topic title isn't defined for a topic, it uses the H1. In addition, it updates the text on the browser tab to reflect the document.title, rather than the original title.

When inspecting a topic in Chrome, a <title data-title> element is present and includes the modified document title:
Code: Select all
<title data-title="[Product Line] - [Original Topic Title] - Documentation | [Company Name]">[Product Line] - [Original Topic Title] - Documentation | [Company Name]</title>

However, when looking at the topic source code, the <title> is unchanged. And I believe this may be what GA looks at?

So, what I'd like to do (I think) is overwrite the <title> in the source code of the generated topics with:
[%=Global/Global.Title%] - [%=System.Title%] - Documentation | Company

So that in the generated topics, it resolves to:
Code: Select all
<title>[Product Line] - [Original Topic Title] - Documentation | [Company Name]</title>

Is there a relatively simple way to accomplish this using the master page or similar?

Or am I way off base, and does GA "inspect" the topic content rather than the topic source code?

Propellus Maximus
Posts: 547
Joined: Wed Mar 05, 2008 10:50 am

Return to Web-based Outputs

Who is online

Users browsing this forum: No registered users and 5 guests