diff --git a/packages/@ourworldindata/grapher/src/core/GrapherAnalytics.ts b/packages/@ourworldindata/grapher/src/core/GrapherAnalytics.ts index 3720bab652d..43e8ca50201 100644 --- a/packages/@ourworldindata/grapher/src/core/GrapherAnalytics.ts +++ b/packages/@ourworldindata/grapher/src/core/GrapherAnalytics.ts @@ -41,7 +41,7 @@ type countrySelectorEvent = interface GAEvent { event: EventCategory eventAction?: string - eventContext?: string | Record + eventContext?: string eventTarget?: string grapherPath?: string } diff --git a/site/SiteAnalytics.ts b/site/SiteAnalytics.ts index d8837ddb625..9af87e4e533 100644 --- a/site/SiteAnalytics.ts +++ b/site/SiteAnalytics.ts @@ -41,7 +41,12 @@ export class SiteAnalytics extends GrapherAnalytics { this.logToGA({ event: EventCategory.SiteSearchClick, eventAction: "click", - eventContext: { query, position, positionInSection, filter }, + eventContext: JSON.stringify({ + query, + position, + positionInSection, + filter, + }), eventTarget: url, }) } @@ -58,7 +63,7 @@ export class SiteAnalytics extends GrapherAnalytics { this.logToGA({ event: EventCategory.SiteInstantSearchClick, eventAction: "click", - eventContext: { query, position }, + eventContext: JSON.stringify({ query, position }), eventTarget: url, }) }