Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.6k views
in Q2A Core by
Include the JavaScript SDK on your page once, ideally right after the opening <body> tag.

 

How can I add this code after <body> tag?

I tried layout but it did not work.
by
Which theme do you use?
by
I use Candy theme
by
I tried in theme as jatin.soni mentioned but theme was crashed then I removed code. Could you tell me can I add through admin panel?

2 Answers

0 votes
by
reshown by
If you have and Advance theme, you can overwrite the body function like this:

function body()
        {
            $this->output('<body');
            $this->body_tags();
            $this->output('>');
            
            //The custom part starts here
            $this->output("The code you want to write in here");
            
            $this->body_script();
            $this->body_header();
            $this->body_content();
            $this->body_footer();
            $this->body_hidden();
                
            $this->output('</body>');
        }

if you don't have an advance theme you can change the qa-include/qa-theme-base.php, but if you upgrade, you will lose that part of the website.
+3 votes
by
edited by

DO NOT OVERRIDE entire body() function for adding just a script after the opening body tag. There is a function to add body script after opening the body tag.

Use below to add js after opening body tag

function body_script()
{
    qa_html_theme_base::body_script();

    $this->output('<script>YOUR JS SCRIPT HERE</script>');
}
by
Sorry, you're right, didn't notice the body_script(), thanks for correcting me :)
Only sad it took 14h to answer this question.
by
No problem. It happens.

Sometime it takes time, Because, most of the people in community not live on the board all the time but as they get some time :)
by
The only problem is that there are questions that are made for 4-5 days that don't get any answer, and if q2a is to get better I think that we need to try to help everyone, and thank that there are people that know better if someone says something wrong :P
...