From 844131c861335f1bcf27c7a18b722e22aa673e5a Mon Sep 17 00:00:00 2001 From: Stanley Peng Date: Wed, 6 Aug 2025 23:39:51 -0700 Subject: [PATCH] add analytics tags to search submit --- spec/src/modules/tracker.js | 2 ++ src/modules/tracker.js | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/spec/src/modules/tracker.js b/spec/src/modules/tracker.js index 000ef290..e808b818 100644 --- a/spec/src/modules/tracker.js +++ b/spec/src/modules/tracker.js @@ -1506,6 +1506,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { const optionalParameters = { groupId: 'group-id', displayName: 'display-name', + analyticsTags: testAnalyticsTag, }; it('Backwards Compatibility - V2 Should respond with a valid response when term and snake cased parameters are provided', (done) => { @@ -1750,6 +1751,7 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => { group_id: optionalParameters.groupId, display_name: optionalParameters.displayName, }); + expect(requestParams).to.have.property('analytics_tags').to.deep.equal(testAnalyticsTag); // Response expect(responseParams).to.have.property('method').to.equal('GET'); diff --git a/src/modules/tracker.js b/src/modules/tracker.js index 301800a5..e6dd639c 100644 --- a/src/modules/tracker.js +++ b/src/modules/tracker.js @@ -593,6 +593,7 @@ class Tracker { * @param {string} parameters.originalQuery - The current autocomplete search query * @param {string} [parameters.groupId] - Group identifier of the group to search within. Only required if searching within a group, i.e. "Pumpkin in Canned Goods" * @param {string} [parameters.displayName] - Display name of group of selected item + * @param {object} [parameters.analyticsTags] - Pass additional analytics data * @param {object} [networkParameters] - Parameters relevant to the network request * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds) * @returns {(true|Error)} @@ -621,6 +622,7 @@ class Tracker { groupId = group_id, display_name, displayName = display_name, + analyticsTags, } = parameters; if (originalQuery) { @@ -634,6 +636,10 @@ class Tracker { }; } + if (analyticsTags) { + queryParams.analytics_tags = analyticsTags; + } + this.requests.queue(`${url}${applyParamsAsString(queryParams, this.options)}`, undefined, undefined, networkParameters); this.requests.send();