Manage your cookies in custom mode
If you don't have a developer in your team, we recommend that you use Google Tag Manager (free tool 100% free provided by Google : tagmanager.google.com)
CUSTOM JAVASCRIPT INTEGRATION A "cookies:complete" event is dispatched.

1. Video presentation

2. Cookies integration

Before going throught this step, it is necessary that you followed the sdk integration part and finished the configuration of the cookies that you want to add. If this isn't done you can check :
List all cookies that you want to add and go to your website backoffice.
Let's take the hubspot tag for example
1
Loading code given by Hubspot.
2
<!-- Start of HubSpot Embed Code -->
3
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/XXXXXXX.js"></script>
4
<!-- End of HubSpot Embed Code -->
Copied!
It is HTML code so we can't use it that way. We have to translate it to Javascript The login given in the script URL corresponds to the client ID that allows Hubspot to identify your account. We chose to add it as a parameter to be clearer.
1
function loadHubspot(clientId) {
2
var el = document.createElement('script');
3
el.setAttribute('id', 'hs-script-loader');
4
el.setAttribute('type', 'text/javascript');
5
el.setAttribute('async', true);
6
el.setAttribute('defer', true);
7
el.setAttribute('src', '//js.hs-scripts.com/'+clientId+'js');
8
document.body.append(el);
9
}
Copied!
You can then copy paste the function on your back office and the script will be loaded on your site. Now you juste have to configure the cookie deposit on click on the Axeptio cookie widget. For this :
1
void 0 === window._axcb && (window._axcb = []);
2
window._axcb.push(function(axeptio) {
3
axeptio.on("cookies:complete", function(choices) {
4
if(choices.hubspot) {
5
loadHubspot(0000000);
6
}
7
})
8
});
Copied!
A fully clear, informed and unambiguous consent is necessary before the cookie deposit on the site 👊

3. Example for Google Analytics

Go search the Google Analitycs script.
1
Loading code given by Google Analytics.
2
<!-- Start of Google Analytics -->
3
<script>
4
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
5
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
6
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
7
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
8
9
ga('create', 'UA-00000000-1', 'auto');
10
ga('send', 'pageview');
11
12
</script>
13
<!-- End of Google Analytics -->
Copied!
You now translate it to Javascript so you can copy and paste the function to your back office. Now all there is left is to configure the cookie deposit on click on the Axeptio cookie widget, which gives :
1
function launchGA() {
2
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
3
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
4
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
5
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
6
ga('create', 'UA-00000000-1', 'auto');
7
ga('send', 'pageview');
8
}
9
10
void 0 === window._axcb && (window._axcb = []);
11
window._axcb.push(function(axeptio) {
12
axeptio.on("cookies:complete", function(choices) {
13
if(choices.google_analytics) {
14
launchGA();
15
}
16
})
17
});
Copied!

4. Example for the Facebook pixel and Google analytics

Go search the Facebook Pixel script :
1
<!-- Facebook Pixel Code -->
2
<script>
3
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
4
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
5
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
6
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
7
document,'script','https://connect.facebook.net/en_US/fbevents.js');
8
9
fbq('init', '159702201342042');
10
fbq('set','agent','tmgoogletagmanager', '159702201342042');
11
fbq('track', "PageView");
12
</script>
13
<noscript><img height="1" width="1" style="display:none"
14
src="https://www.facebook.com/tr?id=159702201342042&ev=PageView&noscript=1"
15
/></noscript>
16
<!-- End Facebook Pixel Code -->
Copied!
You now translate it to Javascript so you can copy and paste the function to your back office. Now all there is left is to configure the cookie deposit on click on the Axeptio cookie widget, which gives :
1
function launchFB() {
2
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
3
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
4
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
5
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
6
document,'script','https://connect.facebook.net/en_US/fbevents.js');
7
8
fbq('init', '159702201342042');
9
fbq('set','agent','tmgoogletagmanager', '159702201342042');
10
fbq('track', "PageView");
11
}
12
13
function launchGoogleAnalytics() {
14
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
15
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
16
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
17
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
18
ga('create', 'UA-00000000-1', 'auto');
19
ga('send', 'pageview');
20
}
21
22
void 0 === window._axcb && (window._axcb = []);
23
window._axcb.push(function(axeptio) {
24
axeptio.on("cookies:complete", function(choices) {
25
if(choices.facebook_pixel) {
26
launchFB();
27
}
28
if(choices.google_analytics) {
29
launchGoogleAnalytics();
30
}
31
});
32
});
Copied!
Congratulations ! Everythings works perfectly ! 🤘
Last modified 8mo ago