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

This commit is contained in:
Björn Fromme
2026-03-16 12:02:59 +01:00
parent e5803860df
commit 9eefdd1858
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
});
}
}
}