{"id":3816,"date":"2026-06-03T16:36:41","date_gmt":"2026-06-03T16:36:41","guid":{"rendered":"https:\/\/gaconnector.com\/docs\/?p=3816"},"modified":"2026-06-03T16:39:16","modified_gmt":"2026-06-03T16:39:16","slug":"integrating-ga-connector-with-cookieyes-consent-banner","status":"publish","type":"post","link":"https:\/\/gaconnector.com\/docs\/integrating-ga-connector-with-cookieyes-consent-banner\/","title":{"rendered":"Integrating GA Connector with CookieYes"},"content":{"rendered":"<p>This guide shows you how to make GA Connector work properly with CookieYes. The goal is simple: the GA Connector script should only run after a visitor accepts analytics cookies, never before. We\u2019ll also make sure its cookies are categorized correctly so your banner and cookie policy stay accurate.<\/p>\n<h2>Before you start<\/h2>\n<p>You\u2019ll need:<\/p>\n<ul>\n<li>A CookieYes account with the banner already installed in the <code>&lt;head&gt;<\/code>, before your other scripts.<\/li>\n<li>Access to edit your site\u2019s HTML (or your GTM container).<\/li>\n<\/ul>\n<h2>Step 1: Check which integration type you\u2019re using<\/h2>\n<p>GA Connector comes in two integration types, and the script you need is different for each. Confirm which one your site uses by following <a href=\"https:\/\/gaconnector.com\/docs\/how-to-check-which-ga-connector-integration-type-youre-using\/\">How to Check Which GA Connector Integration Type You\u2019re Using<\/a>.<\/p>\n<p>The quick version: view your page source, search for <code>gaconnector.js<\/code>, and look at the subdomain. <code>tc.<\/code> or <code>tracker.<\/code> means Cookie-Based; <code>ta.<\/code> or <code>track.<\/code> means API-Based.<\/p>\n<p>Then follow the matching script below.<\/p>\n<div class=\"gac-callout gac-note\">\n<p><span class=\"gac-label\">Running both integrations?<\/span><\/p>\n<p>If your page source contains <strong>both<\/strong> a cookie-based subdomain (<code>tc.<\/code> or <code>tracker.<\/code>) and an API-based one (<code>ta.<\/code> or <code>track.<\/code>), you\u2019re running both integrations in parallel. This is fully supported \u2014 just make sure you replace <strong>both<\/strong> scripts using the two sections below.<\/p>\n<\/div>\n<h2>Step 2: Load GA Connector after consent<\/h2>\n<p>Both scripts below wait for CookieYes and load GA Connector only once the visitor accepts analytics cookies. Place your chosen script on every page, below the CookieYes banner script, and leave the code as-is.<\/p>\n<div class=\"gac-callout gac-warning\">\n<p><span class=\"gac-label\">Don\u2019t reload the page on consent.<\/span><\/p>\n<p>Turn off any CookieYes (or theme\/plugin) setting that reloads or redirects the page the moment consent is given, because a reload might break the attribution.<\/p>\n<\/div>\n<h3>If you use the Cookie-Based integration<\/h3>\n<p>Use this script:<\/p>\n<pre><code><script>\r\n(function () {\r\n    var GACONNECTOR_SRC = 'https:\/\/tc.gaconnector.com\/gaconnector.js';\r\n\r\n    function loadGaconnectorScript() {\r\n        if (window.__gaconnectorScriptInjected) return;\r\n        window.__gaconnectorScriptInjected = true;\r\n        var ra = document.createElement('script');\r\n        ra.type = 'text\/javascript';\r\n        ra.src = GACONNECTOR_SRC;\r\n        ra.async = true;\r\n        ra.setAttribute('data-cfasync', 'false');\r\n        ra.onload = function () {\r\n            if (!startGaconnector()) tryInitWithBackoff(2000);\r\n        };\r\n        \/\/ Insert before the first script, or fall back to <head>\r\n        var s = document.getElementsByTagName('script')[0];\r\n        if (s && s.parentNode) {\r\n            s.parentNode.insertBefore(ra, s);\r\n        } else {\r\n            document.head.appendChild(ra);\r\n        }\r\n    }\r\n\r\n    function setGaconnectorHiddenFields() {\r\n        if (!window.gaconnector || !gaconnector.getCookieValues) return;\r\n        var gaFields = gaconnector.getCookieValues();\r\n        for (var fieldName in gaFields) {\r\n            if (!gaFields.hasOwnProperty(fieldName)) continue;\r\n            var selectors = 'form input[name=\"' + fieldName + '\"], form input#' + fieldName +\r\n                ', form input#field_' + fieldName + ', form input[name=\"' + fieldName.toLowerCase() + '\"], form input#' +\r\n                fieldName.toLowerCase() + ', form input#field_' + fieldName.toLowerCase() +\r\n                ', input[value=\"gaconnector_' + fieldName + '\"],' +\r\n                'form textarea[name=\"' + fieldName + '\"], form textarea#' + fieldName + ', form textarea#field_' + fieldName +\r\n                ', form textarea[name=\"' + fieldName.toLowerCase() + '\"], form textarea#' + fieldName.toLowerCase() +\r\n                ', form textarea#field_' + fieldName.toLowerCase() + ', form textarea.' + fieldName +\r\n                ', form textarea[name=\"param[' + fieldName + ']\"], form textarea[id^=\"field_' + fieldName + '\"]';\r\n            var inputs = document.querySelectorAll(selectors);\r\n            if (!inputs) continue;\r\n            for (var i = 0; i < inputs.length; i++) { inputs[i].value = gaFields[fieldName]; } } } function startGaconnector() { if (!window.gaconnector || !gaconnector.setCallback) return false; if (window.__gaconnectorStarted) return true; window.__gaconnectorStarted = true; try { gaconnector.setCallback(setGaconnectorHiddenFields); } catch (e) {} setGaconnectorHiddenFields(); if (!window.__gaconnectorInterval) { window.__gaconnectorInterval = setInterval(setGaconnectorHiddenFields, 1000); } return true; } function tryInitWithBackoff(maxMs) { var start = Date.now(); var iv = setInterval(function () { if (startGaconnector() || Date.now() - start > maxMs) {\r\n                clearInterval(iv);\r\n            }\r\n        }, 150);\r\n    }\r\n\r\n    function handleConsentUpdate(eventData) {\r\n        var data = eventData && eventData.detail;\r\n        if (data && data.accepted && data.accepted.indexOf('analytics') !== -1) {\r\n            loadGaconnectorScript();\r\n        }\r\n    }\r\n\r\n    document.addEventListener('cookieyes_banner_load', function (eventData) {\r\n        var data = eventData && eventData.detail;\r\n        if (data && data.categories && data.categories.analytics) {\r\n            loadGaconnectorScript();\r\n        }\r\n    });\r\n    document.addEventListener('cookieyes_consent_update', handleConsentUpdate);\r\n})();\r\n<\/script><\/code><\/pre>\n<h3>If you use the API-Based integration<\/h3>\n<p>The API-based version doesn\u2019t use hidden fields, so the script is shorter. Use this script, and <strong>replace <code>YOUR_ACCOUNT_ID<\/code> at the top with your own GA Connector account ID<\/strong>:<\/p>\n<pre><code><script>\r\n(function () {\r\n    var ACCOUNT_ID = 'YOUR_ACCOUNT_ID'; \/\/ <-- Replace with your GA Connector account ID\r\n    var GACONNECTOR_SRC = 'https:\/\/ta.gaconnector.com\/gaconnector.js';\r\n\r\n    function loadGaconnectorScript() {\r\n        if (window.__gaconnectorApiScriptInjected) return;\r\n        window.__gaconnectorApiScriptInjected = true;\r\n        var ra = document.createElement('script');\r\n        ra.type = 'text\/javascript';\r\n        ra.src = GACONNECTOR_SRC;\r\n        ra.async = true;\r\n        ra.setAttribute('data-cfasync', 'false');\r\n        ra.onload = function () {\r\n            if (window.gaconnector2 &#038;&#038; gaconnector2.track) {\r\n                gaconnector2.track(ACCOUNT_ID);\r\n            }\r\n        };\r\n        var s = document.getElementsByTagName('script')[0];\r\n        if (s &#038;&#038; s.parentNode) {\r\n            s.parentNode.insertBefore(ra, s);\r\n        } else {\r\n            document.head.appendChild(ra);\r\n        }\r\n    }\r\n\r\n    function handleConsentUpdate(eventData) {\r\n        var data = eventData &#038;&#038; eventData.detail;\r\n        if (data &#038;&#038; data.accepted &#038;&#038; data.accepted.indexOf('analytics') !== -1) {\r\n            loadGaconnectorScript();\r\n        }\r\n    }\r\n\r\n    document.addEventListener('cookieyes_banner_load', function (eventData) {\r\n        var data = eventData &#038;&#038; eventData.detail;\r\n        if (data &#038;&#038; data.categories &#038;&#038; data.categories.analytics) {\r\n            loadGaconnectorScript();\r\n        }\r\n    });\r\n    document.addEventListener('cookieyes_consent_update', handleConsentUpdate);\r\n})();\r\n<\/script><\/code><\/pre>\n<div class=\"gac-callout gac-warning\">\n<p><span class=\"gac-label\">Set your account ID.<\/span><\/p>\n<p>The API-based script won\u2019t track anything until you replace <code>YOUR_ACCOUNT_ID<\/code> with your actual GA Connector account ID. Leaving the placeholder in means no data is sent.<\/p>\n<\/div>\n<h3>Adding the script through Google Tag Manager<\/h3>\n<p>If you\u2019d rather manage the script in GTM, add it as a <strong>Custom HTML<\/strong> tag with the script for your integration type. Set the trigger to <strong>All Pages<\/strong> (All Pageviews), and turn off any consent checks or consent-based triggers on the tag.<\/p>\n<div class=\"gac-callout gac-warning\">\n<p><span class=\"gac-label\">Don\u2019t add a second consent gate in GTM.<\/span><\/p>\n<p>The script already waits for CookieYes consent on its own. If you also add a consent check or consent-based trigger to the GTM tag, the two gates will conflict and the script won\u2019t load. Trigger on <strong>All Pages<\/strong> and let the script handle consent.<\/p>\n<\/div>\n<h2>Step 3: Categorize the GA Connector cookies in CookieYes<\/h2>\n<p>So your banner and cookie policy describe GA Connector correctly, re-scan your site in the CookieYes dashboard (Cookie Manager, then scan). Once the scan finishes, make sure every cookie starting with the <code>gaconnector_<\/code> prefix is categorized as <strong>Analytics<\/strong>. Move any that landed under Uncategorized into the Analytics category, then publish your changes.<\/p>\n<h2>Checking that it works<\/h2>\n<ol>\n<li>Open your site in a private window, or clear all cookies first.<\/li>\n<li>Open your browser\u2019s developer tools, go to the <strong>Application<\/strong> tab, and find <strong>Cookies<\/strong>.<\/li>\n<li>Before you accept the banner, confirm no <code>gaconnector<\/code> cookies are present.<\/li>\n<li>Accept analytics, reload, and confirm GA Connector loads. For the cookie-based integration, you should now see the <code>gaconnector<\/code> cookies and your form\u2019s hidden fields populated.<\/li>\n<li>If you want to be thorough, decline analytics in a fresh session and confirm nothing loads.<\/li>\n<\/ol>\n<h2>Still stuck?<\/h2>\n<p>If GA Connector isn\u2019t capturing data after consent, or the cookies aren\u2019t behaving the way you expect, contact our support team and include the page where the scripts are installed so we can take a look.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide shows you how to make GA Connector work properly with CookieYes. The goal is simple: the GA Connector script should only run after a visitor accepts analytics cookies, never before. We\u2019ll also make sure its cookies are categorized correctly so your banner and cookie policy stay accurate. Before you start You\u2019ll need: A [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,16],"tags":[],"_links":{"self":[{"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/posts\/3816"}],"collection":[{"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/comments?post=3816"}],"version-history":[{"count":17,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/posts\/3816\/revisions"}],"predecessor-version":[{"id":3835,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/posts\/3816\/revisions\/3835"}],"wp:attachment":[{"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/media?parent=3816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/categories?post=3816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/tags?post=3816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}