Incorporating javascript into the custom javascript box

Posted in: Newspaper
Post count: 3

Hi there, I am trying to use the custom javascript box but it indicates that I should not include script open and closing tags.

If the script I need to incorporate is something like this:

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

What would it look like when I remove those? It seems to validate fine if I take out the second <script> </script> piece but for this line:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

It doesn’t seem to validate.

Post count: 22421

Hello,

Sorry but ads were never meant to be added through the custom js section. If your script code is needed to be shown then you will have to find an alternative way of implementing the js code.

Thank you!

Post count: 3

This is not to display an individual ad. Google now offers auto-ads which means it places them as needed throughout the site. As such, you need one piece of javascript in the header instead of several. Either way, I’ll implement elsewhere but I see no reason why I shouldn’t be able to add this as it’s not to display an ad itself.

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.