Grant Turck

Add Script After Opening Body Tag

6 posts in this topic

What file do I need to add code to in my pl-framework-pagelines child theme to insert script after opening body tag on every page?

Can you someone provide me with the code also?

Share this post

Link to post
Share on other sites

Hey @Grant Turck ... easiest way to do this is with a plugin, or Google Tag Manager (there are WP plugins for it)


if you want to add with a hook, it goes something like this in your function.php in a child theme: 

add_action('wp_footer', 'my_script');

function my_script(){
// script code here



Share this post

Link to post
Share on other sites

Where can I find <body <?php body_class(); ?>> within Pagelines? 

Share this post

Link to post
Share on other sites

why do you need that? you should be using hooks for everything...

It is inside a function call...

Share this post

Link to post
Share on other sites

Because it's how to insert the google tag manager script after the body tag. The second piece of the tag manager script must be placed after the opening body tag (not in the footer). If the script is not placed immediately before the opening body tag then tag manager won't function properly. 


Share this post

Link to post
Share on other sites

try attaching to the pagelines_before_page hook :P

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

  • Similar Content

    • jagipson
      By jagipson+
      Should be a simple answer but not sure why its not doing this.  I have a child theme installed on pagelines 5 that has a hook so it will write over the theme css. Strange is that when I am on the frontend the code works but in the dashboard your theme takes over my code and its no where to be found. See examples attachments
      @Andrew @Danny

    • TallTree
      By TallTree+
      I am trying to remove the sidebar areas from my child theme ( from the post pages on a site:
      The content is all the way to the left and very small, and the two sidebar areas are taking up a lot of space.
      What I'm after is content to the left, taking up most of the space, and then a small sidebar width on the right for widgets.
      I've tried selecting 'read width content' and 'full width content' in the edit screen for the WP content section, but it doesn't change.  If I try to move the sidebars (1 or 2) to the left, it doesn't change.
      If I select the pagelines framework theme (not child), the two sidebars go away when not selecting them in the edit screen..
      Can someone please tell me what I'm doing wrong?
      Thanks in advance.
    • dbrowne02
      By dbrowne02+
      Hi, I noticed that framework and child theme has a number of errors when run through themecheck. The others, like material and bootstrap, don't have any errors when run through theme check. Is there a way to get it so that there are no errors on the child theme?

    • DanatTLFN
      By DanatTLFN
      Hi Pagelines Team,
      I am interested in setting up a bbPress forum on my website.
      Unfortunately, I have never set up a child theme for my site and have been just using the drag and drop system to put together my site on the main theme. If I am to install the child theme, and activate it, what do I stand to lose in terms of design and current configuration settings on the backend?
      Thank you for taking this time to read this.
      Kind regards,
    • flourishdesignstudio
      By flourishdesignstudio+
      I installed the child theme from the extend section. When I activate it and try to go to the site, it looks terrible! I realized that all of my widgets have moved to different sidebars. In addition to that issue is that the Page Editor is a blank area. Custome CSS, Templates, Etc shows up just fine.
      Everything has been updated and is current.
      Has this happened to anyone else? How do I correct it?