Skip to content
Closed
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 @@ -4335,6 +4335,8 @@ describe(`ConstructorIO - Tracker${bundledDescriptionSuffix}`, () => {
resultId: 'result-id',
section: 'Products',
analyticsTags: testAnalyticsTag,
slCampaignId: '019927c2-f955-4020',
slCampaignOwner: 'constructor',
};

it('Backwards Compatibility - Should respond with a valid response when snake cased parameters are provided', (done) => {
Expand Down Expand Up @@ -4563,6 +4565,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
14 changes: 14 additions & 0 deletions src/modules/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,8 @@ class Tracker {
* @param {string[]|string|number} [parameters.seedItemIds] - Item ID(s) to be used as seed
* @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 viewed a set of recommendations
* @example
Expand All @@ -1244,6 +1246,8 @@ class Tracker {
* url: 'https://demo.constructor.io/sandbox/farmstand',
* podId: '019927c2-f955-4020',
* numResultsViewed: 3,
* slCampaignId: '019927c2-f955-4020',
* slCampaignOwner: 'constructor',
* },
* );
*/
Expand All @@ -1268,6 +1272,8 @@ class Tracker {
analyticsTags,
seedItemIds,
resultCount = result_count || items?.length || 0,
slCampaignId,
slCampaignOwner,
Comment on lines +1275 to +1276
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need this here 🤔

I believe we pass slCampaignId and slCampaignOwner via the items array. That seems to be how home24 has it implemented for Search/Browse based on what I see in their beacon. cc @esezen

Screenshot 2025-08-27 at 5 10 37 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jjl014 , just verified this. Thanks for clarifying! Oh yeah it seems that's already supported out of the box for all items schemas. No changes required on either behavioral endpoint or the beacons here 👍.

Will close this PR since it's no longer required.

} = parameters;

if (!helpers.isNil(resultCount)) {
Expand Down Expand Up @@ -1316,6 +1322,14 @@ class Tracker {
bodyParams.seed_item_ids = seedItemIds;
}

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 @@ -145,6 +145,8 @@ declare class Tracker {
resultId?: string;
section?: string;
analyticsTags?: Record<string, string>;
slCampaignId?: string;
slCampaignOwner?: string;
},
networkParameters?: NetworkParameters
): true | Error;
Expand Down
Loading