Jump to content
Sign in to follow this  
wonderwoman

Asynchronous Analytics underneath body tag

Recommended Posts

wonderwoman

I'm inserting FB code for the FB button (yes I know you have handy buttons, but I want to put original code in). I need to put the code in right after the tag, according to FB. Using pagelines custom code, I thought by placing the code in the "asynchronous analytics" section, it would go in the right spot. Unfortunately when I look at the way the code is rendered, pagelines seems to put it just *before* the tag, which is NOT what the help text says it does. Can anyone guide me how I can get the fb javascript code in the right place?

Share this post


Link to post
Share on other sites
Danny
Hi WonderWoman, Can you provide a link to the code you're trying to use please.

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
WebWerx
@wonderwoman: Why not just add it with a Hook?

Share this post


Link to post
Share on other sites
Simon
Yes that boxes description is wrong, the code indeed goes right before /html, to get code after the body tag you need to use a hook. pagelines_before_site would do it. http://paste.pagelines.com/4qn

Share this post


Link to post
Share on other sites
wonderwoman
Okay, I understand a hook is the best way to do this. Sadly, I'm not really understanding hooks. I've read up on them and tried to combine that limited knowledge with what FB says I need to do to add the SDK to my site. I've got something wrong. (I have a clue that I don't have a clue - at least a step in the right direction!) Unfortunately I'm missing something important, as the code isn't in the page. The fbcode seems to be right because when I put it in the footer, the buttons render (but it looks funny because it renders after the rest of the page). But when I'm using the hook, no go. Here's what's in my pagelines-custom/functions.php: ... /* // ==================================================== // = YOUR FUNCTIONS - Where you should add your code = // ==================================================== */ add_action( 'pagelines_before_site'. 'my_add_fb' ); function my_add_fb() { ?>

Share this post


Link to post
Share on other sites
Danny
Hi, Can you link where you're getting this code from please, so I can try this myself.

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
wonderwoman
Hi Danny sorry to take so long to respond. I've done the "wrong" thing and loaded the necessary code into the footer of the page, which makes the button render last, but it works. So I sort of have a workaround. I'd really rather do it the right way, so I've come back... The code I posted above is what is on the following page: https://developers.facebook.com/docs/reference/javascript/ I put this code in, as when you generate the like button code, FB tells you you have to load the SDK in the page before your like button code. Honestly, this is a wee bit over my head, so I've probably done a terribly stupid thing. Just trying to not rely on a bazillion plugins - have better code and control over what displays on my pages. Cheers!

Share this post


Link to post
Share on other sites
Danny
Hi WondaWomen, I'm not entirely sure about this, so I will ask one of our developers for assistance and I will reply here or another support mod will when we have more information.

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Simon
There was a typo in your code. correct working code here: http://paste.pagelines.com/2uj

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×