Site logo

Archived topic

Code Snippets Plugin to Add Adsense script Getting Syntax Error

1 reply · Started by Richard Cannon on June 9, 2017

Viewing posts 1–2 of 2

Good evening,
I have the Code Snippets plugin installed, and only need to copy-paste the Google script that is the initial step to connect my site to AdSense. The instructions are:
Copy the code below
2 Paste it into the HTML of https://www.site.com, between the <head> and </head> tags
3 Check the box and click done when you finish

the google script is: (i've hidden my ID)

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "xx-xxx-xxxxxxxxxxxxxxxxxx",
enable_page_level_ads: true
});
</script>

Then i notify Google once that is done.
When I paste the code into the code snippet editor and activate it, the Plugin deactivates the snippet and gives the message:

The snippet has been deactivated due to an error on line 1:
syntax error, unexpected '<'

The code is exactly as provided by Google. Thanks for any help.

Hi there,

You should add that code into the wp_head hook in GP Hooks instead of using Code Snippets.

This archived topic is closed to new replies.