Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions src/theme/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,38 @@ import { useLocation } from '@docusaurus/router';

const CustomScript = () => {
const location = useLocation();
const currentLanguage = document.documentElement.lang;
useEffect(() => {
if (typeof window !== 'undefined') {
window.dataLayer = window.dataLayer || [];
console.log('Initializing dataLayer for', location.pathname);
window.dataLayer.push({
event: 'pageview',
environment: 'PROD', // es. dev
platform: 'web', // es. web
page_type: 'panel', // es. site
lang: currentLanguage.substring(0, 2),
page: {
url: location.pathname,
title: document.title,
},
});
if (typeof window === 'undefined') {
return;
}
if (window.__initialPageviewPath === location.pathname) {
window.__initialPageviewPath = null;
return;
}
window.dataLayer = window.dataLayer || [];
if (typeof window.pushPageview === 'function') {
window.pushPageview(location.pathname);
window.__initialPageviewPath = null;
return;
}
window.dataLayer.push({
event: 'pageview',
environment: 'prod', // es. dev
platform: 'web', // es. web
page_type: 'site',
order_type: '',
user: {},
lang: (document.documentElement.lang || 'en').substring(0, 2),
page: {
url: location.pathname,
title: document.title,
referrer: document.referrer,
cart_id: '',
},
});
}, [location]); // Esegui di nuovo se cambia la posizione

return null;
return null;
};
export default function CustomLayout(props) {
return (
Expand Down
26 changes: 26 additions & 0 deletions static/js/gtmscript.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
(function (w, d) {
w.dataLayer = w.dataLayer || [];
w.pushPageview = function (pathname) {
var lang = (d.documentElement.lang || 'en').substring(0, 2);
w.dataLayer.push({
event: 'pageview',
environment: 'prod',
platform: 'web',
page_type: 'site',
order_type: '',
user: {},
lang: lang,
page: {
url: pathname || w.location.pathname,
title: d.title,
referrer: d.referrer,
cart_id: '',
},
});
w.__initialPageviewPath = pathname || w.location.pathname;
};

// Deve essere eseguito prima dello snippet GTM, così il container trova i dati già nel dataLayer
w.pushPageview(w.location.pathname);
})(window, document);

(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
Expand Down
1,798 changes: 1,797 additions & 1 deletion static/openapi/auditing.json

Large diffs are not rendered by default.

4,246 changes: 4,245 additions & 1 deletion static/openapi/baremetal-provider.json

Large diffs are not rendered by default.

1,585 changes: 1,584 additions & 1 deletion static/openapi/catalog.json

Large diffs are not rendered by default.

3,826 changes: 3,825 additions & 1 deletion static/openapi/compute-provider.json

Large diffs are not rendered by default.

1,561 changes: 1,560 additions & 1 deletion static/openapi/compute-provider_v1.1.json

Large diffs are not rendered by default.

7,580 changes: 7,579 additions & 1 deletion static/openapi/container-provider.json

Large diffs are not rendered by default.

5,729 changes: 5,728 additions & 1 deletion static/openapi/database-provider.json

Large diffs are not rendered by default.

2,754 changes: 2,753 additions & 1 deletion static/openapi/metering.json

Large diffs are not rendered by default.

13,239 changes: 13,238 additions & 1 deletion static/openapi/network-provider.json

Large diffs are not rendered by default.

3,793 changes: 3,792 additions & 1 deletion static/openapi/project.json

Large diffs are not rendered by default.

4,129 changes: 4,128 additions & 1 deletion static/openapi/schedule-provider.json

Large diffs are not rendered by default.

3,137 changes: 3,136 additions & 1 deletion static/openapi/security-provider.json

Large diffs are not rendered by default.

6,335 changes: 6,334 additions & 1 deletion static/openapi/storage-provider.json

Large diffs are not rendered by default.

Loading