Skip to content

Commit

Permalink
fix(analytics): Fix custom data layer function (#2594)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Capelinha authored Sep 24, 2020
1 parent 93912bc commit 77a9a15
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ export class AngularFireAnalytics {

if (!analyticsInitialized) {
if (isPlatformBrowser(platformId)) {
gtag = (window[GTAG_FUNCTION_NAME] as any) || ((...args: any[]) => {
(window[DATA_LAYER_NAME] as any).push(args);
});
window[DATA_LAYER_NAME] = window[DATA_LAYER_NAME] || [];
// tslint:disable-next-line: only-arrow-functions
gtag = (window[GTAG_FUNCTION_NAME] as any) || (function(..._args: any[]) {
(window[DATA_LAYER_NAME] as any).push(arguments);
});
analyticsInitialized = zone.runOutsideAngular(() =>
new Promise(resolve => {
window[GTAG_FUNCTION_NAME] = (...args: any[]) => {
Expand Down

0 comments on commit 77a9a15

Please sign in to comment.