|
1 | 1 | <% if config[:tech_docs][:ga4_gtm_tracking_id].is_a?(String) && !config[:tech_docs][:ga4_gtm_tracking_id].empty? %> |
2 | 2 | <!-- Google Tag Manager --> |
3 | | - <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': |
4 | | - new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], |
5 | | - j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= |
6 | | - 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); |
7 | | - })(window,document,'script','dataLayer','<%= config[:tech_docs][:ga4_gtm_tracking_id] %>');</script> |
| 3 | + <script> |
| 4 | + const cookies_policy_cookie = document.cookie |
| 5 | + .split('; ') |
| 6 | + .find(cookie => cookie.split('=')[0] === 'cookies_policy') |
| 7 | + ?.split('=')[1] |
| 8 | + |
| 9 | + if (cookies_policy_cookie && JSON.parse(cookies_policy_cookie).usage) { |
| 10 | + (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': |
| 11 | + new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], |
| 12 | + j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= |
| 13 | + 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); |
| 14 | + })(window,document,'script','dataLayer','<%= config[:tech_docs][:ga4_gtm_tracking_id] %>'); |
| 15 | + } |
| 16 | + </script> |
8 | 17 | <!-- End Google Tag Manager --> |
9 | 18 | <% end %> |
0 commit comments