Skip to content

Commit

Permalink
Split view_item_list events
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Jul 22, 2024
1 parent 2dbeed1 commit 04b7931
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions projects/srm/src/app/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,18 @@ export class AnalyticsService {
});
}

this.gtag({
event: 'view_item_list',
ecommerce: {
item_list_name: title,
items: items.map((item, idx) => this.cardToItem(item, idx + 1 + offset))
},
...eventParams
});
while (items.length > 0) {
const itemsBatch = items.splice(0, 10);
this.gtag({
event: 'view_item_list',
ecommerce: {
item_list_name: title,
items: itemsBatch.map((item, idx) => this.cardToItem(item, idx + 1 + offset))
},
...eventParams
});
offset += itemsBatch.length;
}
}
}

Expand Down

0 comments on commit 04b7931

Please sign in to comment.