Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2016-01-27 06:52:24

angel
Member
From: Israel
Registered: 2013-06-18
Posts: 45
Website

Facebook tracking code & Zopim widget

I need to insert the following scripts between the <head> tags.

Can this be done via phplugins?

If so, how please?

<!--Start of Facebook Script-->
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!--End of Facebook Script-->

<!--Start of Zopim Live Chat Script-->
<script type="text/javascript">
var ua = navigator.userAgent.toLowerCase(),
platform = navigator.platform.toLowerCase();
platformName = ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0],
isMobile = /ios|android|webos/.test(platformName);

if (!isMobile) {
window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
_.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');
$.src='//v2.zopim.com/?7CTG7YLVUZLPWXRWbqHONqW5w8SCibXQ';z.t=+new Date;$.
type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
}
</script>
<!--End of Zopim Live Chat Script-->

<!--Start of Facebook Pixel-->
<script>(function() {
  var _fbq = window._fbq || (window._fbq = []);
  if (!_fbq.loaded) {
    var fbds = document.createElement('script');
    fbds.async = true;
    fbds.src = '//connect.facebook.net/en_US/fbds.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(fbds, s);
    _fbq.loaded = true;
  }
  _fbq.push(['addPixelId', 'XXXXXXXXXXXXXX']);
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', 'PixelInitialized', {}]);

</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?id=XXXXXXXXXXXXXX&amp;ev=NoScript" /></noscript>
<!--End of Facebook Pixel-->

Offline

#2 2016-01-27 07:12:40

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Facebook tracking code & Zopim widget

use the ttg_head_end hook:
http://ce4.theturninggate.net/docs/doku … g_head_end

This is also the place where you'd add a link to a custom css stylesheet so you can use the basic instructions, and instead of the link to the css, use your script.
http://ce4.theturninggate.net/docs/doku … custom_css

since you'll need to use echo ' you're also going to need to escape all single quotes in the script (otherwise, the first single quote will close the echo statement and probably break your site). Do that by adding a backslash before all single quotes: \'

Alternatively, you could replace single quotes with double quotes. The easiest way to do either of these things is to place all that text in a plain text editor and then run a find/replace on single quotes.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#3 2016-01-28 05:44:54

angel
Member
From: Israel
Registered: 2013-06-18
Posts: 45
Website

Re: Facebook tracking code & Zopim widget

I am able to do both?

Place a link to a custom css stylesheet and echo in my script?

Offline

#4 2016-01-28 05:59:27

angel
Member
From: Israel
Registered: 2013-06-18
Posts: 45
Website

Re: Facebook tracking code & Zopim widget

I tried it and it works, thank you!

Offline

Board footer

Powered by FluxBB