Streaming live at 10am (PST)

Seo tag title tag change on click away

Hi guys!

I’m relatively new to Webflow. I’m building my first site and i’m absolutely loving the platform so far.

I just wondered if there was any way to change the SEO title tag when a user changes tabs away from your site? Like with this site: https://www.peardropcreative.co.uk/

I discovered in whilst doing some research and I’ve never seen it done before, so I wondered if there’s any way of doing this in Webflow!

Hope you’re all having a great day :relaxed:

1 Like

Hey there & welcome! :raised_hands:

This is pretty quick to do! You need just a small bit of custom JS:

window.onload = function() {

  var pageTitle = document.title;
  var attentionMessage = 'Come Back!';

  document.addEventListener('visibilitychange', function(e) {
    var isPageActive = !document.hidden;

    if(!isPageActive){
      document.title = attentionMessage;
    }else {
      document.title = pageTitle;
    }
  });
};

Best to put inside the "before end of <body>" custom code area inside the “custom code” tab in the project settings.

Here’s an article that explains this code in detail!

If you need help implementing this, just ask!

1 Like

Thanks so much, that’s so helpful! Absolute lifesaver!