Hello,
ich have to link my page with google Adsense for initialising my membership . To do it I have to paste a HTML Code
<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: “ca-pub-XXXXXXXXXXX”,
enable_page_level_ads: true
});
</script>
into the header.php
A few days ago I tried this with the editor. I Paste the code in the functions.php like I read it in another post.
After that my page broke and I had to restore a backup.
Now I am frightened to try a similar step without to be sure what ist to be done.
So I kindly ask for your advice. Which ist the right way to fulfill googles task?
Thank you very much
Hey Grillmeisterronny,
Please, provide your WP credentials.
Best regards,
John Torvik
Hi Ronny,
So that code is supposed to go in the header? If so then please try this in your child theme’s functions.php file:
function ronny_add_adsense_code(){ ?>
<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: “ca-pub-XXXXXXXXXXX”,
enable_page_level_ads: true
});
</script>
<?php }
add_action('wp_head', 'ronny_add_adsense_code');
Best regards,
Rikard