How to add javascript code without script tag

Posted in: Newspaper
Post count: 6

Hello,

To add custom javascript code, theme says “Please do not include the <script> </script>”

However being a noob in coding, i have no idea, how to do that. The JavaScripts I want to use are following:

1:

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

2:

<script src=”https://letreach.com/scripts/scriptjs/xxxxxxxxxxxxxxxx”></script&gt;

3:

<!– Facebook Pixel Code –>
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version=’2.0′;n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,’script’,’https://connect.facebook.net/en_US/fbevents.js&#8217;);

fbq(‘init’, ‘xxxxxxxxxxxxxxxxx’);
fbq(‘track’, “PageView”);</script>
<noscript><img height=”1″ width=”1″ style=”display:none”
src=”https://www.facebook.com/tr?id=xxxxxxxxxx&ev=PageView&noscript=1&#8243;
/></noscript>
<!– End Facebook Pixel Code –>

Kindly tell me how do i add these without <script> as these are inline codes. If I use them as it is, they don’t work correctly, especially on mobile. Please share converted code if possible.

Post count: 22421

Hi,
It seems the js code you are trying to insert is an add code. Ad codes will not work from the custom javascript code. You can try to insert them in the theme ad spots or inside a text block or a raw js element in visual composer. http://screencast.com/t/9ja9ZfKNaSld
Plaease follow the google implementation methods as some ads have to be added in the theme files inside the html head tag. That is found in the root folder of the theme in the header.php file.
Hope this helps.
Thank you!

Post count: 5

HI Bogdan,

I’m trying to embed a form from my marketing automation platform and it’s js. I need it to be displayed on the front page and on the sidebar, and I just can’t figure out how to add it. I’ve tried with the raw html block but that didn’t work. Any advice?

Thanks!

Post count: 20688

Hi,


@maddievararu
They should be providing installation instructions for the code. A dedicated js element does not exist, try to enter the code in simple text elements, check if that works
https://www.screencast.com/t/pymfK0cPTR

Thanks

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