Category: User Generated Content
This integration is only available for Web projects
What to expect
This integration will allow you to define pages and users that were exposed to the Stackla widget.
What we collect
Dynamic Variables
Key | Value | Data Type |
UGC_ST_Widget Displayed | Widget ID : {widgetID} - {widgetName} | Text |
Implementation
Implementation Steps
Please go to the section How to request an integration to see the instructions to enable this integration. You can then return here once completed.
If you have already completed the step above then continue below.
Log into your Stackla account and open the Custom Code Editor
Open the editor in the Inline Tile using the Javascript tab
If you do not already have the .on('widget:ready' callback defined in there then simply copy all of the code below and paste it into this section:
If you already have the .on('widget:ready' callback defined in there then you must only copy the Stackla CS Integration part that is from the top comment down to the bottom (whilst keeping the comments there in case we need to see which version you are running in the future should we need to make any updates)
This is the code
$(document).on('widget:ready', function (e, instance) { instance .on('load', function (e, listData) { /* *Name: Stackla CS Integration *Version: 1.1 */ var topDom = (function () { var i = 0, domain = document.domain, p = domain.split("."), s = "_cs_tld" + (new Date()).getTime(); while (i < (p.length - 1) && document.cookie.indexOf(s + "=" + s) == -1) { domain = p.slice(-1 - (++i)).join("."); document.cookie = s + "=" + s + ";domain=" + domain + ";SameSite=None;Secure"; } document.cookie = s + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=" + domain + ";"; return domain; })(); function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(";"); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == " ") c = c.substring(1, c.length); if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length); } return ""; } var receiveMessage = function (f) { if (f && f.data && f.data.message && f.data.message === "Contentsquare_Stackla_Integration_Launch" && f.data.user_values) { window.removeEventListener("message", receiveMessage, true); var getCookieValues = f.data.user_values; if (getCookieValues) { var splitCookieValues = getCookieValues.split("|"); var ct_uid = splitCookieValues[0]; var _cs_id = splitCookieValues[1]; var _cs_s = splitCookieValues[2]; var _cs_c = splitCookieValues[3]; var _cs_optout = splitCookieValues[4]; if (_cs_id && _cs_s && _cs_c) { if (ct_uid) { document.cookie = "WRUID=" + ct_uid + ";domain=" + topDom + ";path=/;SameSite=None;Secure"; } document.cookie = "_cs_id=" + _cs_id + ";domain=" + topDom + ";path=/;SameSite=None;Secure"; document.cookie = "_cs_s=" + _cs_s + ";domain=" + topDom + ";path=/;SameSite=None;Secure"; document.cookie = "_cs_c=" + _cs_c + ";domain=" + topDom + ";path=/;SameSite=None;Secure"; if (_cs_optout) { document.cookie = "_cs_optout=" + _cs_optout + ";domain=" + topDom + ";path=/;SameSite=None;Secure"; } else { document.cookie = "_cs_optout=;domain=" + topDom + ";path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT;SameSite=None;Secure"; document.cookie = "_cs_optout=;domain=." + document.location.host + ";path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT;SameSite=None;Secure"; } var partition = ""; var guid = ""; var tag_id = ""; var src = ""; if (f.data.partition) { partition = f.data.partition; guid = f.data.guid; src = "https://cdnssl.clicktale.net/" + partition + "/ptc/" + guid + ".js" } else if (f.data.tag_id) { tag_id = f.data.tag_id; src = "https://t.contentsquare.net/uxa/" + tag_id + ".js" } if (src) { var mt = document.createElement("script"); mt.type = "text/javascript"; mt.async = true; mt.src = src; document.getElementsByTagName("head")[0].appendChild(mt); if (e && e.target && e.target.widget_id && e.target.widgetConfig && e.target.widgetConfig.name) { var widgetName = e.target.widgetConfig.name; var widgetID = e.target.widget_id; var pass_dvar_data = { "message": "Contentsquare_Stackla_SendDvar", "widget_name": widgetName, "widget_id": widgetID }; window.top.postMessage(pass_dvar_data, document.referrer); } } } } } }; window.addEventListener("message", receiveMessage, true); var pass_ready_data = { 'message': 'Contentsquare_Stackla_Integration_Ready' }; window.top.postMessage(pass_ready_data, document.referrer); function callback() { if (!disableCallback) { disableCallback = true; var pass_pv_data = { "message": "Contentsquare_Stackla_Pageview", "pv_value": readCookie("_cs_s") }; window.top.postMessage(pass_pv_data, document.referrer); } } var disableCallback = false; window._uxa = window._uxa || []; _uxa.push(["afterPageView", callback]); //Stackla CS Integration End }); });
Verifying it works
You can use the chrome extension to check the results are sent to CS