변수에 있는 값을 Object key로 넣고 싶을 때let properties = {};
let key = '...';
let value = '...';
properties[key] = value;
let arrUtm = window.document.location.search.split('&');
arrUtm[0] = arrUtm[0].substr(1);
if (window.document.location.search) {
let properties = {};
for (let i = 0; i < arrUtm.length; i++) {
let url = arrUtm[i];
let key = url.split('=')[0];
let value = url.split('=')[1];
if (key === 'test1' || key === 'test2' || key === 'test3') {
properties[key] = value;
}
if (i === arrUtm.length - 1) {
window.mixpanel.track('utm', properties);
}
}
}
댓글
댓글 쓰기