SDK with LightCMP

Deployment routes

To implement Gravito LightCMP on your website (or app inside a webview), you will need CMP configuration first. Usually you will get it generated for you by Gravito Admin Portal or you will be handed pre-made configuration. For testing and reference purposes you can review one configuration here.

After configuration is defined on your site:

<script>
var customCSS="";
var gravitoCMPConfig = {...}
window.gravitoCMPConfig = gravitoCMPConfig;
</script>

You can continue by implementing the CMP loading. Examples on this page should work either directly from page template or via Google Tag Manager custom HTML tag.

LightCMP as a standalone deployment (consents are stored to local client-side cookie):

<script>
var gravitoSdkTag = document.createElement("script");
gravitoSdkTag.src = "https://cdn.gravito.net/sdk/gravitoSDK-v1.0.8.js";
gravitoSdkTag.onload = function () {
window.gravito.ready(function () {
gravito.initLightCMP(
"https://cdn.gravito.net/lightcmp",
"VERSION_NUMBER"
);
});
};
document.body.appendChild(gravitoSdkTag);
</script>

Replace “VERSION_NUMBER” with the version you want to use. If you don’t pass any value CMP will use the latest version of core libraries by default.

Next option, same deployment as above (stand-alone) but with Google Consent Mode enabled (requires some special wiring):

<script>
var gravitoSdkTag = document.createElement("script");
gravitoSdkTag.src = "https://cdn.gravito.net/sdk/gravitoSDK-v1.0.7.js";
gravitoSdkTag.onload = function () {
window.gravito.ready(function () {
gravito.initLightCMPWithGCM(
"https://cdn.gravito.net/lightcmp",
"VERSION_NUMBER"
);
});
};
document.body.appendChild(gravitoSdkTag);
</script>

Replace “VERSION_NUMBER” with the version you want to use. If you don’t pass any value CMP will use the latest version of core libraries by default.

LightCMP with Gravito API integration (consents are stored to Gravito profile):

<script>
var gravitoSdkTag = document.createElement("script");
gravitoSdkTag.src = "https://cdn.gravito.net/sdk/gravitoSDK-v1.0.8.js";
gravitoSdkTag.onload = function () {
window.gravito.ready(function () {
gravito.initLightCMPWithBackend(
"https://cdn.gravito.net/lightcmp",
"YOUR_GRAVITO_REGISTERED_DOMAIN",
"VERSION_NUMBER"
);
});
};
document.body.appendChild(gravitoSdkTag);
</script>

Replace “VERSION_NUMBER” with the version you want to use. If you don’t pass any value CMP will use the latest version of core libraries by default.

NOTE: Make sure you have withBackendIntegration:true in gravitoCMPConfig

LightCMP with Google Consent Mode and Gravito API integration:

<script>
var gravitoSdkTag = document.createElement("script");
gravitoSdkTag.src = "https://cdn.gravito.net/sdk/gravitoSDK-v1.0.8.js";
gravitoSdkTag.onload = function () {
window.gravito.ready(function () {
gravito.initLightCMPWithBackendandGCM(
"https://cdn.gravito.net/lightcmp",
"YOUR_GRAVITO_REGISTERED_DOMAIN",
"VERSION_NUMBER"
);
});
};
document.body.appendChild(gravitoSdkTag);
</script>

NOTE: Make sure you have withBackendIntegration:true in gravitoCMPConfig