fix: properly initialize CMP, GTM and data layer for tracking

This commit is contained in:
Björn Fromme
2026-01-27 21:25:03 +01:00
parent 6365e4b24c
commit 93eb08c610
12 changed files with 87 additions and 37 deletions
@@ -0,0 +1,20 @@
import { Controller } from '@hotwired/stimulus';
export default class extends Controller {
static values = {
url: String,
title: String,
userInfo: String
};
connect() {
if (typeof window.dataLayer !== 'undefined') {
window.dataLayer.push({
'event': 'VirtualPageview',
'virtualPageURL': this.urlValue,
'virtualPageTitle': this.titleValue,
'userInfo': this.userInfoValue
});
}
}
}