Skip to content

Commit 77a9a15

Browse files
authored
fix(analytics): Fix custom data layer function (#2594)
Change arrow function to a normal function to use the arguments object as described in the gtag documentation. That way, analytics sends data back to Google again. Fixes #2505
1 parent 93912bc commit 77a9a15

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/analytics/analytics.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ export class AngularFireAnalytics {
6565

6666
if (!analyticsInitialized) {
6767
if (isPlatformBrowser(platformId)) {
68-
gtag = (window[GTAG_FUNCTION_NAME] as any) || ((...args: any[]) => {
69-
(window[DATA_LAYER_NAME] as any).push(args);
70-
});
7168
window[DATA_LAYER_NAME] = window[DATA_LAYER_NAME] || [];
69+
// tslint:disable-next-line: only-arrow-functions
70+
gtag = (window[GTAG_FUNCTION_NAME] as any) || (function(..._args: any[]) {
71+
(window[DATA_LAYER_NAME] as any).push(arguments);
72+
});
7273
analyticsInitialized = zone.runOutsideAngular(() =>
7374
new Promise(resolve => {
7475
window[GTAG_FUNCTION_NAME] = (...args: any[]) => {

0 commit comments

Comments
 (0)