Dynamic page title with external DB data

Hi,

My App works with an external DB, postgresql.
Everything works well, except dynamically creating page title on the page SEO.

The issue is that the page is first loaded, then the SQL code is executed and then the page title is populated.

Which looks ok to the user, but makes and issue with sharing the page, analytics reports, google search console, etc.

They all show the same page title (I have over 10k pages).
This is due to the time gap between the page load and the SQL query execution.

Is there any way to force the SQL query to be executed before page load?
I’d hate to copy this data to bubble DB and maintain 2 data DBs.

Will appreciate any tip.

1 Like

Anyone?

What plugin do you use to access the external db?

You could try this javascript in the page header. It should complete before the page is fully loaded:

$(document).ready(function() {
  document.title = "New Page Title";
});

If that works you can figure out the best method to load the dynamic page title from Bubble/API/External DB. I have no idea if this will solve your SEO problem. I wouldn’t think having Bubble “cache” your page title data would be a big deal, but I don’t know your data structure.

I use bubble.io native db plugin

Thanks
But this won’t work.
I still needs to execute the db api call to populate the page name. So it’s the same issue as I face now .

$(document).ready(function() {
document.title = “get New Page Title from external db”;
});

Sharing, google analytics and google search console capture the data before the db call is executed. So all of my page titles looks empty.