Page title showing Null for some pages

Hi Snowplowers,
Recently we are seeing an issue with automatically generating the page title column for some pages.
Please see the screenshow below for the title tag in the DOM:


So you can see that the Title tag is filled, however in “tp2”, the “page” field is not there:

And so in bigquery the page title is not filled.

It the root cause of this issue is Title tag not being set correctly?
All other pages work fine except this

Is your page title generating dynamically? If so, I imagine it’s resolving after the tracker fires the page view (therefore, there is no title yet).

You can manually set the page title when tracking a page view:

JS Tracker v3 snippet

snowplow('trackPageView', { title: 'my custom page title' });

Not dynamic. Refer to below graph, the tile is in the doc. It’s better not use custom parameter, as there are too many pages.

Just to be sure that there is nothing weird happening with the page title, could you perhaps log the page title at the same time as you call snowplow('trackPageView');? Just put a console.log(document.title); before the page view call and see what it tells you.

Hi,
we don’t call snowplow(‘trackPageView’) manually in code but using “@analytics/snowplow”: “^0.2.5”,
if type in console, we could get it as below.

If I’m reading that right, you get the title in the page view that you triggered from the console (I assume the first on in the table that you posted is the newer one).

But I wanted to see what is the output of document.title when the page is being initialized and tracking is set up, not when you call it from the console. I am not familiar with the @analytics/snowplow package, but I assume that you make a call like analytics.page() to track a page view? That’s when you should make sure to have the page title present. Could you add the console.log(document.title) call at that exact place to debug this?

This looks like a bug in v0.2.5 of @analytics/snowplow and/or @analytics.

Here the title is always being set, from the payload which the base analytics page generates: analytics/browser.js at @analytics/snowplow@0.2.5 · DavidWells/analytics · GitHub

There is now a v0.3.3 release of this library, which uses v3 of the Snowplow JavaScript Tracker (and no longer requires you to load an external sp.js file). You could try and upgrade to that and see if it helps.

1 Like

For the best results though, use the Snowplow Browser Tracker directly in your app: @snowplow/browser-tracker - npm

1 Like

Thanks, we’ll try it later. Now we found that it only work after we run pageview after window loaded instead of dom ready.