Go to Google Tag Manager Setup. You should receive to Javascript code snippet you need to add to your website, one in the header and one just after the body starts.
There are two simple hooks you can use:
add_action('wp_head', 'add_my_code_to_header');
function add_my_code_to_header(){
?>
In short, open your theme’s functions.php and enter the following code. You can either switch the GTM ID or copy the whole thing:
add_action('wp_head', 'add_google_analytics_code_to_header');
function add_google_analytics_code_to_header(){
?>
Refresh your page and try to verify the installation in Google Tag Manager!