【发布时间】:2019-01-23 11:57:54
【问题描述】:
我正在尝试在我们的网站中实施 Smartlook。我们正在使用 React,所以我不能直接执行文档建议的操作: https://smartlook.github.io/docs/web/gdpr/
我们通过 index.html 中的脚本标签初始化 Smartlook
<script type="text/javascript">
window.smartlook ||
(function(d) {
var o = (smartlook = function() {
o.api.push(arguments);
}),
h = d.getElementsByTagName("head")[0];
var c = d.createElement("script");
o.api = new Array();
c.async = true;
c.type = "text/javascript";
c.charset = "utf-8";
c.src = "https://rec.smartlook.com/recorder.js";
h.appendChild(c);
})(document);
smartlook("init", "somerandomstring");
</script>
我向用户展示了一个可以选择加入的模式,当他选择加入时,这个功能就会被触发:
setCookie = accept => {
const consentText = "Blabalbal";
this.setState({ showModal: false });
const date = new Date();
date.setTime(date.getTime() + 360 * 24 * 60 * 60 * 1000);
const expires = `expires=${date.toUTCString()}`;
document.cookie = `acceptTracking=${accept};${expires};path=/`;
window.smartlook("consentIP", accept ? consentText : false);
window.smartlook("consentAPI", accept ? consentText : false);
console.log(window.smartlook);
if (accept) {
ReactPiwik.push(["rememberConsentGiven"]);
}
};
根据文档,this.should 创建一个名为同意的属性。最初,记录的对象如下所示: 不幸的是,该财产存在,但未经同意。执行我的函数后,整个 smartlook 对象如下所示: 所以它保存了数据,只是不在正确的位置,这对我来说几乎毫无价值。有人知道如何解决这个问题吗?
【问题讨论】:
标签: javascript reactjs tracker