HELP: Adding a snippet after opening tag on each page

  • Unknown's avatar

    Hi, I’m looking to add a Facebook SKD (analytics) to my site. It’s telling me to do the following..

    The following snippet of code will give the basic version of the Facebook SDK for JavaScript where the options are set to their most common defaults. Insert the following code snippet directly after the opening <body> tag on each page you want to use Facebook Analytics. Replace {your-app-id} with the App ID of your web page:

    <script>
    window.fbAsyncInit = function() {
    FB.init({
    appId : ‘{your-app-id}’,
    xfbml : true,
    version : ‘v2.10’
    });
    FB.AppEvents.logPageView();
    };

    (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/sdk.js”;
    fjs.parentNode.insertBefore(js, fjs);
    }(document, ‘script’, ‘facebook-jssdk’));
    </script>

    If someone could explain how I can do this in the simplest form (due to the fact i’m not the most experienced when it comes to wordpress), that would be much appreciated.

    The blog I need help with is http://www.thebritishfeed.com

  • Unknown's avatar

    Hi,

    I think I can point you in the right direction. I can see that the site you referenced above http://www.thebritishfeed.com is not hosted at WordPress.com. While the site hosted there is a WordPress site, it is another version known as WordPress.org. You can get help adding the code above in one of two ways; you can contact your host support directly, or you can contact WordPress.org support through the following link:

    https://wordpress.org/support/

    For more information on the difference between WordPress.com and WordPress.org please visit the following link:

    WordPress.com vs. WordPress.org

    Best of luck!

  • Unknown's avatar

    My site is hosted from guru so may be hard to actually get support unfortunately. Is there no plug-in that’s able to do this for me?

    Seems so hard to just add a code into body tag of each post, I was told it was simple :P

  • Unknown's avatar

    @brandonlt, I would suggest contacting the theme author, or posting in the WordPress.org forums. Generally what you are going to have to do is to create a Child Theme and then add the code to the appropriate theme php script file in the correct place. I’m not familiar with the theme you are using, or how it is structured, so I can’t give you any further details, but the people over at the support forums at WordPress.org should be able to help you out.

  • The topic ‘HELP: Adding a snippet after opening tag on each page’ is closed to new replies.