Embed Salesmanago code into a Grav website


#1

Hi there,
Does anyone here know the easiest and best way to embed Salesmanago code into a Grav website.

Together with the Script I got the following description from Salesmanago:

“To implement your code just copy and paste it into your website’s source code,
before the end of section”

Any ideas?


#2

Hi @gaatec, in general this code (JavaScript I am assuming) could be added to one of the Twig files of your current theme. In order to not get this possibly removed when a theme update happens you should first make an inherited theme: https://learn.getgrav.org/themes/customization#theme-inheritance

If you provide the name of the theme you are using I might be able to give you more specific info.


#3

Hi there, and thanks a lot for replying.
I am using the Clean Blog v1.4.2 theme

Best Reg.
Goran


#4

Are you trying to add a contact form within an iframe? If so, you should be able to do this by editing the template file contact.html.twig within the folder user/themes/clean-blog/templates/.

In the above file look for this:

    <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        {{ page.content }}
        {% include "forms/form.html.twig" with { forms: "contact-form" } %}
    </div>

And try to replace the code between the two div tags with your SALESmanago iframe code:

    <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        <iframe src=""></iframe>
    </div>

#5

Hi again,
I simply want to add the Salesmanago code to every page, so that Salesmanago can track the visits, etc.

In the Salesmanago description, they ask me to add the code before the end of the /body section.
The code is indeed Javascript.


#6

Ah, a-ok for that you could want to add the JavaScript to the base.html.twig file in the folder `user/themes/clean-blog/templates/partials’

There, scroll down until you see this…

        {% block bottom %}
        {{ assets.js() }}
    {% endblock %}
 </body>
</html>

Then add your JavaScipt just before the end of body tag, like this:

        {% block bottom %}
        {{ assets.js() }}
    {% endblock %}

    PASTED CODE HERE

 </body>
</html>

Let me know if that works for you.


#7

Excellent,
Will give it a try and let you know how it work.

Thanks a lot Paul, highly appreciated.

Reg.
Gøran


#8

Hi again Paul,
Your suggestion did indeed sort this out for me.

Thanks a lot, couldn’t have done this without your help.

Reg.
Gøran