Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions spec/src/modules/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4911,6 +4911,8 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => {
resultId: 'result-id',
section: 'Products',
analyticsTags: testAnalyticsTag,
slCampaignOwner: 'Campaign Man',
slCampaignId: 'Campaign 123',
};

it('Backwards Compatibility - Should respond with a valid response when snake cased parameters are provided', (done) => {
Expand Down Expand Up @@ -5186,6 +5188,8 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => {
expect(requestParams).to.have.property('result_id').to.equal(optionalParameters.resultId);
expect(requestParams).to.have.property('section').to.equal(optionalParameters.section);
expect(requestParams).to.have.property('analytics_tags').to.deep.equal(testAnalyticsTag);
expect(requestParams).to.have.property('sl_campaign_id').to.deep.equal(optionalParameters.slCampaignId);
expect(requestParams).to.have.property('sl_campaign_owner').to.deep.equal(optionalParameters.slCampaignOwner);

// Response
expect(responseParams).to.have.property('method').to.equal('POST');
Expand Down
12 changes: 12 additions & 0 deletions src/modules/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,8 @@ class Tracker {
* @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)
* @param {string} [parameters.slCampaignId] - Pass campaign id of sponsored listing
* @param {string} [parameters.slCampaignOwner] - Pass campaign owner of sponsored listing
* @returns {(true|Error)}
* @description User clicked an item that appeared within a list of recommended results
* @example
Expand Down Expand Up @@ -1395,6 +1397,8 @@ class Tracker {
item_name,
itemName = item_name,
analyticsTags,
slCampaignId,
slCampaignOwner,
} = parameters;

if (variationId) {
Expand Down Expand Up @@ -1445,6 +1449,14 @@ class Tracker {
bodyParams.analytics_tags = analyticsTags;
}

if (slCampaignId) {
bodyParams.sl_campaign_id = slCampaignId;
}

if (slCampaignOwner) {
bodyParams.sl_campaign_owner = slCampaignOwner;
}

const requestURL = `${requestPath}${applyParamsAsString({}, this.options)}`;
const requestMethod = 'POST';
const requestBody = applyParams(bodyParams, { ...this.options, requestMethod });
Expand Down
2 changes: 2 additions & 0 deletions src/types/tracker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ declare class Tracker {
resultPositionOnPage?: number;
numResultsPerPage?: number;
analyticsTags?: Record<string, string>;
slCampaignId?: string;
slCampaignOwner?: string;
},
networkParameters?: NetworkParameters
): true | Error;
Expand Down
Loading