How do I add Contextly scripts to my Ghost site's header and footer?

In order for Contextly to show recommendations on a Ghost site and collect smart analytics, we need to run two scripts to get and show the recommendations.

 

There are two things you need to do - both quite simple.

1. Add Contextly's script to the Ghost Header

2. Add another Contextly script to the Ghost Footer

 

Video How To:

How To:

1. First, go to your Ghost control panel, usually at yoursitename.com/ghost

2. On the left side, look for the gear icon at the bottom left and click it

3. Scroll down and look for Code Injection

4. In the HEADER section - on a new line, copy and paste this code:

<script>

!function(w,d,id,ns,s){var c=w[ns]=w[ns]||{};if(c.ready||(c.q=[],c.ready=function(){c.q.push(arguments)}),!d.getElementById(id)){var e=d.createElement(s);e.id=id,e.src="https://assets.context.ly/kit/6.latest/loader.js";var h=d.getElementsByTagName(s)[0];h.parentNode.insertBefore(e,h)}}(window,document,"ctx-loader","Contextly","script");

</script>

 

5. In the FOOTER section, on a new line, copy and paste this code:

<script>

    Contextly.ready('widgets');

</script>

 

6. Press Save in the top right corner of the Ghost page

 

That's all you need to do with the scripts.

 

This is the second part of the integration (after creating an API key for Contextly) and the final step is modifying your theme to show the recommendations.

 

 

Have more questions? Submit a request

Comments