How can I incorporate affiliate references in the buy button HTML code?

Topic summary

A partner using the buy button sales channel needs to include their affiliate reference code in the implementation, but the HTML code breaks when adding the affiliate parameter to the domain attribute.

Current Issue:

  • The affiliate ref looks like: ?sca_ref=1975285.hOicNlbYZC
  • Adding this to the domain URL in the ShopifyBuy.buildClient() configuration causes the buy button to stop functioning

Technical Context:

  • The code uses the Shopify Buy Button SDK with JavaScript
  • The domain is currently set as a plain string: 'natural-elements-uk.myshopify.com'
  • The partner needs a way to append or incorporate the affiliate tracking parameter without breaking the buy button functionality

Status: The question remains unanswered with no solution provided yet for how to properly include affiliate references in the buy button implementation.

Summarized with AI on November 10. AI used: claude-sonnet-4-5-20250929.

We have partners who offer our products on their site using the buy button sales channel. One such partner is an affiliate and wants their affiliate ref to be used when using the buy button html code.

The html code stops working when the domain attribute has their affiliate ref code added to the url.

here is an example:

function ShopifyBuyInit() {
var client = ShopifyBuy.buildClient({
domain: ‘natural-elements-uk.myshopify.com’,
storefrontAccessToken: ‘6e76c6873fabc267d8cc9c61f8177198’,
});
ShopifyBuy.UI.onReady(client).then(function (ui) {
ui.createComponent(‘collection’, {
id: ‘430655766742’,
node: document.getElementById(‘collection-component-1709639326956’),
moneyFormat: ‘%C2%A3%7B%7Bamount%7D%7D’,
options: {

“product”: {
“styles”: {
“product”: {

.

.

.

Their affiliate ref looks like this ‘?sca_ref=5825791.hOicNlbYZC’ … but how can i include this in the about code

All comments welcome

Nigel