How to add code before body <tag>?

Hi, I’ve signed up to a Live Chat plugin called Tawk.To - in the set-up instructions it says to add JavaScript Code before the body .

See here: https://www.tawk.to/knowledgebase/getting-started/adding-a-widget-to-your-website/

How do I do this?

Apologies to ask (what I assume is) a really simple question. Thanks for your help.

Best,
David.

Hello David,

Thanks for asking. :slight_smile:

An easier alternative to integrate Tawk.to to your website would be to use there official WordPress plugin. I am sharing the relevant links that you can take a look.

https://www.tawk.to/knowledgebase/plugins-and-modules/add-a-tawk-to-widget-to-wordpress/

However, if you would like to go with the JS code option, then please add following code in child theme function.php file:

add_action( 'x_before_site_begin', 'chat_script' );
function chat_script(){
?>
   <!-- chat_script code here -->
<?php
}

You can use following resources to download and setup child theme.

Download Child theme from following source: https://theme.co/apex/child-themes

Please take a look at following article to setup child theme:

https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.