Skip to content

Commit c9a5fb4

Browse files
committed
Allow custom url for googletagmanager service Fix #1399
1 parent f4e1cd1 commit c9a5fb4

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

‎tarteaucitron.services.js‎

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3664,8 +3664,13 @@ tarteaucitron.services.googleads = {
36643664
return;
36653665
}
36663666

3667+
var customDomain = "www.googletagmanager.com";
3668+
if (tarteaucitron.user.googleadsCustomDomain !== undefined && tarteaucitron.user.googleadsCustomDomain !== "") {
3669+
customDomain = tarteaucitron.user.googleadsCustomDomain;
3670+
}
3671+
36673672
window.dataLayer = window.dataLayer || [];
3668-
tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + tarteaucitron.user.googleadsId, '', function () {
3673+
tarteaucitron.addScript('https://' + customDomain + '/gtag/js?id=' + tarteaucitron.user.googleadsId, '', function () {
36693674
window.gtag = function gtag() { dataLayer.push(arguments); }
36703675
gtag('js', new Date());
36713676
var additional_config_info = (timeExpire !== undefined) ? {'anonymize_ip': true, 'cookie_expires': timeExpire / 1000} : {'anonymize_ip': true};
@@ -3710,8 +3715,13 @@ tarteaucitron.services.gtag = {
37103715
return;
37113716
}
37123717

3718+
var customDomain = "www.googletagmanager.com";
3719+
if (tarteaucitron.user.gtagCustomDomain !== undefined && tarteaucitron.user.gtagCustomDomain !== "") {
3720+
customDomain = tarteaucitron.user.gtagCustomDomain;
3721+
}
3722+
37133723
window.dataLayer = window.dataLayer || [];
3714-
tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + tarteaucitron.user.gtagUa, '', function () {
3724+
tarteaucitron.addScript('https://' + customDomain + '/gtag/js?id=' + tarteaucitron.user.gtagUa, '', function () {
37153725
window.gtag = function gtag() { dataLayer.push(arguments); }
37163726
gtag('js', new Date());
37173727
var additional_config_info = (timeExpire !== undefined) ? {'anonymize_ip': true, 'cookie_expires': timeExpire / 1000} : {'anonymize_ip': true};
@@ -4016,7 +4026,13 @@ tarteaucitron.services.googletagmanager = {
40164026
'gtm.start': new Date().getTime(),
40174027
event: 'gtm.js'
40184028
});
4019-
tarteaucitron.addScript('https://www.googletagmanager.com/gtm.js?id=' + tarteaucitron.user.googletagmanagerId);
4029+
4030+
var customDomain = "www.googletagmanager.com";
4031+
if (tarteaucitron.user.googletagmanagerCustomDomain !== undefined && tarteaucitron.user.googletagmanagerCustomDomain !== "") {
4032+
customDomain = tarteaucitron.user.googletagmanagerCustomDomain;
4033+
}
4034+
4035+
tarteaucitron.addScript('https://' + customDomain + '/gtm.js?id=' + tarteaucitron.user.googletagmanagerId);
40204036
},
40214037
"fallback": function () {
40224038
if (tarteaucitron.parameters.googleConsentMode === true) {
@@ -4046,8 +4062,13 @@ tarteaucitron.services.multiplegoogletagmanager = {
40464062
event: 'gtm.js'
40474063
});
40484064

4065+
var customDomain = "www.googletagmanager.com";
4066+
if (tarteaucitron.user.multiplegoogletagmanagerCustomDomain !== undefined && tarteaucitron.user.multiplegoogletagmanagerCustomDomain !== "") {
4067+
customDomain = tarteaucitron.user.multiplegoogletagmanagerCustomDomain;
4068+
}
4069+
40494070
tarteaucitron.user.multiplegoogletagmanagerId.forEach(function (id) {
4050-
tarteaucitron.addScript('https://www.googletagmanager.com/gtm.js?id=' + id);
4071+
tarteaucitron.addScript('https://' + customDomain + '/gtm.js?id=' + id);
40514072
});
40524073

40534074
},
@@ -5714,9 +5735,14 @@ tarteaucitron.services.multiplegtag = {
57145735
"use strict";
57155736
window.dataLayer = window.dataLayer || [];
57165737

5738+
var customDomain = "www.googletagmanager.com";
5739+
if (tarteaucitron.user.multiplegtagCustomDomain !== undefined && tarteaucitron.user.multiplegtagCustomDomain !== "") {
5740+
customDomain = tarteaucitron.user.multiplegtagCustomDomain;
5741+
}
5742+
57175743
if (tarteaucitron.user.multiplegtagUa !== undefined) {
57185744
tarteaucitron.user.multiplegtagUa.forEach(function (ua) {
5719-
tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + ua, '', function () {
5745+
tarteaucitron.addScript('https://' + customDomain + '/gtag/js?id=' + ua, '', function () {
57205746
window.gtag = function gtag() { dataLayer.push(arguments); }
57215747
gtag('js', new Date());
57225748
var additional_config_info = (timeExpire !== undefined) ? {'anonymize_ip': true, 'cookie_expires': timeExpire / 1000} : {'anonymize_ip': true};

‎tarteaucitron.services.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)