diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 3dbccd7..b996ede 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2011,6 +2011,40 @@ tarteaucitron.services.analytics = { } }; +// google ads +tarteaucitron.services.googleads = { + "key": "googleads", + "type": "ads", + "name": "Google Ads", + "uri": "https://policies.google.com/privacy", + "needConsent": true, + "cookies": (function () { + var googleIdentifier = tarteaucitron.user.googleadsId, + tagUaCookie = '_gat_gtag_' + googleIdentifier, + tagGCookie = '_ga_' + googleIdentifier; + + tagUaCookie = tagUaCookie.replace(/-/g, '_'); + tagGCookie = tagGCookie.replace(/G-/g, ''); + + return ['_ga', '_gat', '_gid', '__utma', '__utmb', '__utmc', '__utmt', '__utmz', tagUaCookie, tagGCookie, '_gcl_au']; + })(), + "js": function () { + "use strict"; + window.dataLayer = window.dataLayer || []; + tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + tarteaucitron.user.googleadsId, '', function () { + window.gtag = function gtag() { dataLayer.push(arguments); } + gtag('js', new Date()); + var additional_config_info = (timeExpire !== undefined) ? {'anonymize_ip': true, 'cookie_expires': timeExpire / 1000} : {'anonymize_ip': true}; + + gtag('config', tarteaucitron.user.googleadsId, additional_config_info); + + if (typeof tarteaucitron.user.googleadsMore === 'function') { + tarteaucitron.user.googleadsMore(); + } + }); + } +}; + // google analytics tarteaucitron.services.gtag = { "key": "gtag",