Get a Demo

Output code within the page body

Under Settings -> Analytics & Custom CodeBlock in the administration, you can set some custom code to output after the opening <body> tag.

A common use could be some tracking code to show on all pages. Or, you may need to set a portion of the Google Tag Manager code.

In order to use that code in your templates, you must set the following tag somewhere in your templates.

 
{{ _page.bodyStartCodeBlock() }}

Set the opening <body> tag code in your templates. Link

You can also add code to be output after the opening <body> tag in your templates. This code will only be output with the {{ _page.bodyStartCodeBlock() }} tag.

There are two methods to add the code. 

If your code is short or saved to a variable then you can do the following.

{% do _page.addBodyStartCodeBlock('MY_CODE_HERE') %}

If your code is multiple lines then you can do the following.\

 
{% bodyStartCodeBlock %}
<script>
  const var = 'Some longer code here';
</script>
{% endBodyStartCodeBlock %}

Output code before the closing </body> tag Link

Under Settings -> Analytics & Custom CodeBlock in the administration, you can set some custom code to output before the closing </body> tag. 

An example use case would be if you need to set the Javascript code to use a chat tool.

In order to use that code in your templates, you must set the following tag somewhere in your templates.

{{ _page.bodyEndCodeBlock() }}

Set the closing </body> tag code in your templates. Link

You can also add code to be output before the closing </body> tag in your templates. This code will only be output with the {{ _page.bodyEndCodeBlock() }} tag.

There are two methods to add the code. 

If your code is short or saved to a variable then you can do the following.

 
{% do _page.addBodyEndCodeBlock('<script>Some code here</script>') %}

If your code is multiple lines then you can do the following.\

 
{% bodyEndCodeBlock %}
<script>
  const var = 'Some longer code here';
</script>
{% endBodyEndCodeBlock %}
Get Started With Aptuitiv