{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/fr/products/clickwrap/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Consents","description":"Integration and usage documentation."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"consents","__idx":0},"children":["Consents"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This section provides guidance on embedding an existing clickwrap in your website using Namirial Clickwrap. The clickwrap is a collection of agreements configured in the Agreements section, that users must accept to use your website or application."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"required-data","__idx":1},"children":["Required data"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Data Element"},"children":["Data Element"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["enviroment"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["This field is mandatory and receives two values 'staging' or 'production' as input"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["cwGuid"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["This is a mandatory element and represents a GUID value that identifies the group to which the agreement created in the Namirial Clickwrap web app belongs"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["version"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["This is a non-mandatory element and gives the possibility to insert a specific version of an agreement in your application, if omitted it will return the last active version based on the selected environment."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["customValidation"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["This is a mandatory element, it accepts 3 parameters: browser, namirial or bootstrap."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["messaggeValidation"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["This is a non-mandatory element and must only be used if you take advantage of the custom validation of the library, which allows you to customize the message to be displayed in case of failure to enter a mandatory agreement."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["CSSclassesList"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["This is a mandatory element and is used to insert a CSS class at the beginning of the agreement box"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["After these parameters we need to insert a unique id field within our configuration, id that will allow us to know where to redirect the called agreement."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"write-your-html-for-embedding-the-clickwrap","__idx":2},"children":["Write your HTML for embedding the clickwrap"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The code you need to embed your clickwrap on your web page includes two HTML tags:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["<div>"]}," indicating where the agreement should be displayed."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["<script>"]}," tag which contains the import of the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["namirial_wrap.js"]}," library and the use of the render method with pre-configured parameters listed in the previous section and which are used to identify your agreement"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["There are two mandatory fields for displaying the agreement:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["enviroment"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["cwGuid"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["It is not necessary to assign a value to the other parameters to retrieve the agreement, if you do not want to take advantage of the custom validation or do not want to assign a custom css class to the agreement's container, just leave the value blank"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"html","header":{"controls":{"copy":{}}},"source":"<!-- HTML wrapper for rendering -->\n<div id=\"namirial__click-wrap\"></div>\n\n<!-- Initialization of the agreement snippet -->\n\n<script type=\"module\">\n  /*  Javascript library for business logic  */\n\n  import { clickWrap } from \"{url of the desired environment (see get started page)}\";\n\n  clickWrap.render(\n    {\n      enviroment: \"staging\",\n      cwGuid: \"0e4995f4-388f-4b2a-9e0e-6a71671e1238\",\n      version: \"\",\n      customValidation: \"browser\",\n      messageValidation: \"Your Custom message\",\n      CSSclassesList: [\"css_class_1\", \"css_class_2\", \"css_class_N\"],\n    },\n    \"#namirial__click-wrap\"\n  );\n</script>\n","lang":"html"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"use-of-the-field-collection","__idx":3},"children":["Use of the Field Collection"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In order to collect the user's consent, it is necessary to enter the ID parameters that correspond to the Field Collections entered during the agreement configuration phase and that correspond to the required parameters, secondly it is necessary to intercept the submit event through a Javascript function"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This configuration allows the retrieval of the form data through the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["namirial_wrap.js"]}," library and to block the sending of the consent in the event that some of this data has not been entered"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The parameters entered will be collected when sending the consent expressed by the user, the data collected will then be available in the consent detail sidebar in the clickwrap dashboard"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/integration_field_collections.90f7b951b77572f573425a11056c82cfae29265a6a8e5b645dcaaedf2617aafa.b0ae38d6.svg","alt":"field collection","title":"field collections"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"use-of-external-id","__idx":4},"children":["Use of External ID"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The External ID is the key that identifies the user who is present on the system that integrates the clickwrap snipett, it is a mandatory field for the purpose of registering the consent"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The data used to generate the external ID value may or may not be a field of the may or may not belong to the fields of the form in which the clickwrap is inserted, there is no uniqueness constraint associated with this field by the namirial_wrap library, it is highly recommended to integrate dynamic values such as email or guid in order to improve and facilitate any research in our systems through the integrator Api"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"submit-event-with-browser-validation","__idx":5},"children":["Submit event with browser validation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The customValidation parameter of the rendering method just illustrated allows you to take advantage of the custom validation of the agreement, if you do not want to take advantage of this option it will be sufficient to write the word \"browser\" as a parameter or simply leave the field blank"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You will first need to select the submit button of the form, where the clickwrap has been placed, through a specific class or an id using the querySelector method and assign a submit event to this button via the Javascript addEventListener method"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Once this operation has been carried out, it is necessary to place the sendingConsents() method of the namirial_wrap library inside the callback function of the addEventListener method"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This method takes as input a parameter of type ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}," called ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["externalID"]}," and represents the id of the user who is expressing consent"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Having left to the browser the burden of validating the fields of the form in the event that a user has not validated a required field, the submission of the form will be automatically blocked"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"js","header":{"controls":{"copy":{}}},"source":"const submitBtn = document.querySelector(\"<the submit button of your form>\");\n\nconst form = document.querySelector(\"#<id of my form>\");\nconst MyFormSubmitHandler = () => {\n  let externalId = \"<external id value chosen>\";\n  clickWrap.sendingConsents(externalId);\n};\n\nsubmitBtn.addEventListener(\"click\", MyFormSubmitHandler);\n","lang":"js"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"submit-event-with-custom-validation","__idx":6},"children":["Submit event with custom validation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The namirial_wrap library provides two types of validation:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["namirial"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["bootstrap"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can choose the type of validation using \"bootstrap\" or \"namirial\" as input parameter for the customValidation field"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["namirial_wrap.js"]}," library will automatically insert two parameters in the form where the arrangement will be rendered:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The novalidate attribute which disables data checks carried out automatically by the browser"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A different class depending on the validation you have chosen to use:"," ","If you have chosen bootstrap validation, the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".needs-validation"]}," class will be added"," ","If you have chosen namirial validation instead, the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".namirial-form-validation"]}," class will be added"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["HTML form validation is applied via CSS’s two pseudo-classes, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[":invalid"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[":valid"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"html","header":{"controls":{"copy":{}}},"source":"<!-- HTML wrapper for rendering -->\n<div id=\"namirial__click-wrap\"></div>\n\n<!-- Initialization of the agreement snippet -->\n\n<script type=\"module\">\n  /*  Javascript library for business logic  */\n\n  import { clickWrap } from \"{url of the desired environment (see get started page)}\";\n\n  clickWrap.render(\n    {\n      enviroment: \"staging\",\n      cwGuid: \"0e4995f4-388f-4b2a-9e0e-6a71671e1238\",\n      version: \"\",\n      customValidation: \"namirial || bootstrap\",\n      messageValidation: \"Your Custom message\",\n      CSSclassesList: [\"css_class_1\", \"css_class_2\", \"css_class_N\"],\n    },\n    \"#namirial__click-wrap\"\n  );\n</script>\n","lang":"html"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"demo-css-integration-for-custom-validation","__idx":7},"children":["Demo css integration for custom validation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To use the css classes for custom validation you will need to add the following css's to your style sheet, including the css belonging to the validation you have decided to implement"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["::: details Namirial css"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"css","header":{"controls":{"copy":{}}},"source":"form.namirial-validation\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:invalid\n  ~ label {\n  color: #d46f62;\n}\n\nform.namirial-validation\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:invalid\n  ~ label\n  span {\n  border: 3px solid #d46f62;\n}\n\nform.namirial-validation\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:invalid:focus\n  ~ label\n  span {\n  border: 3px solid #d46f62;\n  box-shadow: 0 0 0 0.25rem rgb(212 111 98 / 25%);\n}\n\n.invalid-feedback {\n  display: none;\n  width: 100%;\n  margin-top: 0.25rem;\n  font-size: 0.875em;\n  color: #d46f62;\n}\n\nform.namirial-validation\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  :invalid\n  ~ .invalid-feedback {\n  display: block;\n}\n\nform.namirial-validation\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:valid\n  ~ label\n  span {\n  border: 3px solid #5fb99f;\n}\n\nform.namirial-validation\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:valid:focus\n  ~ label\n  span {\n  border: 3px solid #5fb99f;\n  box-shadow: 0 0 0 0.25rem rgb(95 185 159 / 25%);\n}\n\nform.namirial-validation\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:valid\n  ~ label\n  span::after {\n  background-color: #5fb99f;\n}\n","lang":"css"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[":::"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["::: details Bootstrap css"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"css","header":{"controls":{"copy":{}}},"source":"form.was-validated\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:invalid\n  ~ label {\n  color: #dc3545;\n}\n\nform.was-validated\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:invalid\n  ~ label\n  span {\n  border: 3px solid #dc3545;\n}\n\nform.was-validated\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:invalid\n  ~ label {\n  color: #dc3545;\n}\n\nform.was-validated\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:invalid:focus\n  ~ label\n  span {\n  border: 3px solid #dc3545;\n  box-shadow: 0 0 0 0.25rem rgb(220 53 69 / 25%);\n}\n\nform.was-validated\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:valid\n  ~ label\n  span {\n  border: 3px solid #198754;\n}\n\nform.was-validate\n  #namirial__click-wrap\n  .namirial-cw\n  .namirial-cw__field-group\n  input:required:valid\n  ~ label\n  span {\n  border: 3px solid #198754 !important;\n}\n\nform.was-validated\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:valid:focus\n  ~ label\n  span {\n  border: 3px solid #198754;\n  box-shadow: 0 0 0 0.25rem rgb(25 135 84 / 25%);\n}\n\nform.was-validated\n  #namirial__click-wrap\n  .namirial-cw__field-group\n  input:valid\n  ~ label\n  span::after {\n  background-color: #198754;\n}\n","lang":"css"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[":::"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"submit-event-interception-with-browser-validation","__idx":8},"children":["Submit event interception with browser validation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["By eliminating the browser default validation, it is necessary to integrate a condition within the callback function of the addEventListener method in which to insert the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["isValidCheck()"]}," method of the library and pass to the method the id entered as a parameter"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This function will take care of verifying that the agreements set as mandatory have been correctly validated"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In order for the consent to be collected correctly, it will be necessary insert the sendigConsents method inside the condition previously set"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"js","header":{"controls":{"copy":{}}},"source":"const submitBtn = document.querySelector(\"<the submit button of your form>\");\n\nconst form = document.querySelector(\"#<id of my form>\");\nconst MyFormSubmitHandler = () => {\n  if (clickWrap.isValidCheck(\"#test\") === false) return;\n  let externalId = \"<external id value chosen>\";\n  clickWrap.sendingConsents(externalId);\n};\n\nsubmitBtn.addEventListener(\"click\", MyFormSubmitHandler);\n","lang":"js"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"custom-events","__idx":9},"children":["Custom events"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["namirial_wrap.js"]}," library provides two custom events:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["namirial-renderAgreement"]},": used for managing the rendering of the recovery of the agreement to be integrated"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["namirial-onError"]},": for handling http and library configuration errors."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["namirial-onApproved"]},": used to collect the user's newly registered consent."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The information handled by each of the three events can be retrieved through the event parameter of the addEventListner method, in the object of the method there is the detail key that can be used to retrieve the error or confirmation message or, in the case of the \"namirial-renderAgreement\" event, the boolean value that indicates the end of the process of retrieving and rendering the arrangement"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["It is advisable to send the data of your application within the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["namirial-onApproved"]}," event, in order to retrieve the consentGroupGuid parameter and to be able to search for the consents expressed by users through the APIs made available by clickwrap"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"js","header":{"controls":{"copy":{}}},"source":"const form = document.querySelector(\"#id of my form\");\n\nwindow.addEventListener(\n  \"namirial-onApproved\",\n  function (e) {\n    // ajax call made to the server\n    fetch(\"your endpoint\", {\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application/json;charset=utf-8\",\n      },\n      //The contract in your form\n      body: JSON.stringify(e.detail),\n    }).then((res) => res);\n\n    //Sending the form to the server\n    form.submit();\n  },\n  false\n);\n","lang":"js"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"js","header":{"controls":{"copy":{}}},"source":"window.addEventListener(\n  \"namirial-onError\",\n  function (e) {\n    console.log(e.detail);\n  },\n  false\n);\n","lang":"js"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"js","header":{"controls":{"copy":{}}},"source":"window.addEventListener(\n  \"namirial-onApproved\",\n  function (e) {\n    console.log(e.detail);\n  },\n  false\n);\n","lang":"js"},"children":[]}]},"headings":[{"value":"Consents","id":"consents","depth":1},{"value":"Required data","id":"required-data","depth":2},{"value":"Write your HTML for embedding the clickwrap","id":"write-your-html-for-embedding-the-clickwrap","depth":2},{"value":"Use of the Field Collection","id":"use-of-the-field-collection","depth":2},{"value":"Use of External ID","id":"use-of-external-id","depth":2},{"value":"Submit event with browser validation","id":"submit-event-with-browser-validation","depth":2},{"value":"Submit event with custom validation","id":"submit-event-with-custom-validation","depth":2},{"value":"Demo css integration for custom validation","id":"demo-css-integration-for-custom-validation","depth":2},{"value":"Submit event interception with browser validation","id":"submit-event-interception-with-browser-validation","depth":2},{"value":"Custom events","id":"custom-events","depth":2}],"frontmatter":{"seo":{"title":"Consents"}},"lastModified":"2025-06-11T14:22:17.000Z","isTranslationFallback":true,"pagePropGetterError":{"message":"","name":""}},"slug":"/fr/products/clickwrap/snippet-integration/consents","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}