お気軽にご質問・ご相談ください
フォーム送信完了後、担当者よりご連絡させていただきます。
// Cookieから指定した名前の値を取得する関数 function getCookieValue(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; } document.addEventListener('DOMContentLoaded', function() { console.log('DOMContentLoaded'); var checkHubspotForm = setInterval(function() { if (window.hbspt) { clearInterval(checkHubspotForm); hbspt.forms.create({ region: "na1", portalId: "22641786", formId: "ac11b939-7767-4123-b3e2-11569ff55d83", sfdcCampaignId: "7017F0000013pskQAA", onFormReady: function($form, ctx) { console.log('Form is ready.'); var cookieValue = getCookieValue('_gcid'); console.log('Cookie Value:', cookieValue); if (cookieValue) { var hiddenField = jQuery('input[name="e_ga_clientid"]'); if (hiddenField.length > 0) { console.log('Hidden field found!'); hiddenField.val(cookieValue); console.log('Value set:', hiddenField.val()); } else { console.log('Hidden field not found.'); } } else { console.log('_gcid cookie not found.'); } } }); } }, 100); });