Adding a snippet after opening tag on each page
-
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: (visible only to logged in users)
-
Hi,
I think I can point you in the right direction. I can see that the site you referenced above is hosted at DreamHost. 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 DreamHost support directly, or you can contact WordPress.org support through the following link:
https://wordpress.org/support/
I’d recommend starting with DreamHost and going from there. For more information on the difference between WordPress.com and WordPress.org please visit the following link:
Best of luck!
-
Is your blog here? http://www.justviral.co/
If not, could you please verify the URL to the blog where you need assistance? The link you provided does not work.
-
The link you provided appears to be broken.
To add on to what the others have mentioned… This applies if you are hosted with wordpress.com. In the interest of security, unless you have a Business plan Javascript is not supported on WordPress.com sites. You can read more on the code support page.However if you’d like some analytics, you can still use the <noscript> version of Facebook’s Pixel analytics. https://en.support.wordpress.com/facebook-integration/#facebook-pixel
I hope that helps.
In the event you are not hosted with wordpress.com you’ll need to contact your hosting provider.
-
@brandonlt, it appears you are self-hosted and are using the Cubic theme. For self-hosted sites such as yours, there is a dedicated Cubic Support Forum at WordPress.org where you can post your questions. Since Cubic is a child theme already, you will likely have to create a plugin to insert that code since you cannot make a child theme of a child theme, and if you make the changes to the original theme files, your changes will get overwritten each time the theme gets updated.
- The topic ‘Adding a snippet after opening tag on each page’ is closed to new replies.