/* */ function scanSetGCLID(contentId) { var gclidRegex = /[&\?]gclid=([^&]*?)(&|$)/; var gclid = gclidRegex.exec(window.location.search) ? gclidRegex.exec(window.location.search)[1] : null; if (!gclid) { return; } var _isIpHidedDevice = function() { var _ua = window.navigator.userAgent.toLowerCase(); // safariを含むか if (_ua.indexOf("safari") === -1) { return false; } // chrome, edgeはuaにsafariに文字を含むので判定 if (_ua.indexOf("chrome") > 0) { return false; } if (_ua.indexOf("edge") > 0) { return false; } if (/(iphone|ipad|mac os x)/.test(_ua) === false) { return false; } var _CHECK_MIN_VER = 14; var _versionRegex = /version\/(\d+)/; var _version = _versionRegex.exec(_ua) ? _versionRegex.exec(_ua)[1] : _CHECK_MIN_VER; // versionが取れなかった場合はtrue return _version >= _CHECK_MIN_VER; } if (_isIpHidedDevice()) { const _SCAN_TRC_DOMAINS = ["act.scadnet.com", "ad.scadnet.com"]; document.querySelectorAll("a[href*=\"scadnet.com\"]").forEach(function(e) { let _url = new URL(e.href); if (!_SCAN_TRC_DOMAINS.includes(_url.host)) { return; } _url.searchParams.append("gclid", encodeURIComponent(gclid)); e.href = _url.href; }); return; } var apiUrl = "https://api.scadnet.com/collabo/setGoogleClickId.php?cid=" + contentId + "&gclid=" + gclid; var xhr = new XMLHttpRequest(); xhr.open("GET", apiUrl, true); xhr.send(); }