You can integrate GatedContent.com into your Kontent.ai account to quickly and easily embed gates within your content.


Creating a custom element to select gates

To do this, first create a new Content model within Kontent.ai. As part of your content model, add a "Custom element" in the area where you want gates to appear. Configure this Custom element as follows:


Hosted code URL (HTTPS): https://admin.gatedcontent.com/accounts/XXXXXXXX/gateselector/kontentai


Element required: Set as desired 


Replace 'XXXXXXXX' in the URL above with your GatedContent.com account ID. Check with your account manager if you're not sure what this is.


Once your content model is ready, your editors can use it to directly embed gates into the content. To do this, your editors will need to have a GatedContent.com user account and will be asked to sign in using their credentials from within the Kontent.ai interface. After doing so, they can then select gates to embed.


Rendering gates on a webpage

Once you have a content model and some content pieces with gates on them, follow these steps to render the gates on a webpage:


1. Ensure that your target webpage has the GatedContent.com installation script on it from your account (you can find this under the Help menu within our admin portal)


2. Use the Kontent.ai Delivery API to retrieve your content item. The embed code for your gate can be retrieved, as a string, from the value property of the field that you integrated our gate selector against as a Custom element in the above section. So for example, if using the JavaScript SDK, the relevant line of code to retrieve the embed code might look something like the below, where {gate_field_name} is the name of the field you integrated against:

response.data.item.elements.{gate_field_name}.value
3. Output the retrieved value onto the page using your preferred method (for example, with .innerHTML if using frontend JavaScript).


4. Note that if the gate embed code is rendered on the page after the GCDC installation script has already initialised, you will need to trigger the script to re-scan the page for new gates by following the advice given in this KB article.