• 16 Oct 2023
  • 2 Minutes to read
  • Contributors
  • Dark


  • Dark

Article Summary

With code snippet elements you have the option to publish javascript snippets to the frontend (client side). They will be fetched from the same first party as the JENTIS JS SDK as a single javascript resource.

Please be aware that with those custom codes:

  1. Code Elements by default execute on "JENTIS Framework Load" trigger
    this means whenever JENTIS is initiated on your website.
  2. Code snippets are executed one by one.
    A priority of all those code elements is possible, if a sequence is required. Use the "order" field property in a code element for that purpose. The order of code snippets is from low to high numbers (Integer)
  3. No HTML.
    The field "Javascript Code" only allows the use of Javascript, please do not enter HTML (like "<script>...</script>" - do not use this).


Currently the code elements are limited in some capabilities that we have on our roadmap for the future. Here is a little guide how to work around some common obstacles.


Code elements currently are not assigned to any vendor in the JENTIS consent engine, hence there is no consent information checked or applied to code elements. If consent is an important factor in your custom code, we'd propose that you create a variable that checks the consent of a vendor and based on that an if-condition is applied.

Here is an example for this kind of customization: 

(where "adobeanalytics" is an example for a vendor id, please exchange this to the vendor id that is relevant for your use case; if you are not sure which vendor id it is you can just run the jentis.consent.engine.getVendorFullData() function to get all currently installed vendors in your container)

var my_tool_consent_status = jentis.consent.engine.getVendorFullData()["adobeanalytics"].status;

if(my_tool_consent_status === true){
  ... // continue with custom code if consent is true
} else {
  ... // do something else if no consent

This would need a frontend variable that holds the according tools consent. Please create a custom variable of type "Custom JavaScript" frontend variable.

The code to return the current consent status of a tool in frontend is:

  return jentis.consent.engine.getVendorConsent("mytool");

Please mind here that the vendor id must be provided in the getVendorConsent function call.

More details on working with the consent engine can be found here: Consent Javascript SDK

Add a Code Element

To add a Javascript code snippet to your JENTIS Tag Manager container please follow this steps.

Navigate to the Server Tag Manager: Codes section in your JENTIS Tag Manager account. Click the "+" icon to add a new element.

In a code element you must provide the following fields:

  • Name: a descriptive short name of the code element.
  • Order: a number that defines the order of execution on initialization (Integer). Low numbers are executed first, starting with 0.
  • Containers: select the containers in your JENTIS Tag Manager account, that will include this code element when loaded.
  • Javascript Code: the actual code. Please be aware that this code will be interpreted in a closure and minified, so always mind the scope you are working with.
  • CSS Code (optional): Here you can also add custom CSS to publish to your webpage with this element.
  • Trigger: select a trigger that activates this code, leave it on default "JENTIS Framework Load" to execute immediately.

Was this article helpful?