Skip to content

Commit

Permalink
Load GA4/Google Ads when Google Consent Mode is on
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauriC committed Mar 5, 2024
1 parent 6b651fb commit 71eeae9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion tarteaucitron.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ var tarteaucitron = {
analytics_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
wait_for_update: 510
wait_for_update: 800
});

// if google ads, add a service for personalized ads
Expand Down Expand Up @@ -388,6 +388,11 @@ var tarteaucitron = {
analytics_storage: 'denied'
});
});

// allow gtag/googleads by default if consent mode is on
window.addEventListener('tac.root_available', function() {
tarteaucitron_block.unblock(/www\.googletagmanager\.com\/gtag\/js/);
});
}

// Step 1: load css
Expand Down
2 changes: 1 addition & 1 deletion tarteaucitron.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions tarteaucitron.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -3013,6 +3013,11 @@ tarteaucitron.services.googleads = {
tarteaucitron.user.googleadsMore();
}
});
},
"fallback": function () {
if (tarteaucitron.parameters.googleConsentMode === true) {
this.js();
}
}
};

Expand Down Expand Up @@ -3055,6 +3060,11 @@ tarteaucitron.services.gtag = {
tarteaucitron.user.gtagMore();
}
});
},
"fallback": function () {
if (tarteaucitron.parameters.googleConsentMode === true) {
this.js();
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion tarteaucitron.services.min.js

Large diffs are not rendered by default.

0 comments on commit 71eeae9

Please sign in to comment.