Does anyone have experience with Global site tag (gtag.js) - Google Analytics under Aurelia.
I created a function to push data to the dataLayer object like below
public send_screen_view_gtag(name: string): void {
if (!(<any>window).dataLayer) { (<any>window).dataLayer = []; } console.log((<any>window).dataLayer); (<any>window).dataLayer.push('js', new Date()); (<any>window).dataLayer.push('config', 'G-3NH3SR7B1N'); (<any>window).dataLayer.push('config', 'G-3NH3SR7B1N', { 'page_title' : name, 'page_path': '/' + name }); console.log((<any>window).dataLayer); }
The idea was to call this function from attached on various pages.
I also placed <script async src="https://www.googletagmanager.com/gtag/js?id=G-3NH3SR7B1N"></script>
in my index.ejs file
The trouble is the content of dataLayer never seems to be read or sent to google.
Does anyone have any idea what todo with this ?
I assumed adding <script async src="https://www.googletagmanager.com/gtag/js?id=G-3NH3SR7B1N"></script>
would setup whatever google does to read dataLayer.
Thanks