Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
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.
Which theme do you use?
I use Candy theme
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
reshown by
If you have and Advance theme, you can overwrite the body function like this:

function body()
            //The custom part starts here
            $this->output("The code you want to write in here");

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
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()

    $this->output('<script>YOUR JS SCRIPT HERE</script>');
Sorry, you're right, didn't notice the body_script(), thanks for correcting me :)
Only sad it took 14h to answer this question.
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 :)
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