---
schema_version: "1"
id: 4f8798867e40eb99a7adec17ce26f045ad3b9dae786b1971b545d24dcc4b1455
title: Create a Shareable URL for Your Store
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/commerce/264-0-0/comm_shareableurl.md
canonical_url: https://help.salesforce.com/s/articleView?id=commerce.comm_shareableurl.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 6ea94f76e3c384d1238c38f9699ea0db3150ad590fd44f05e192f1090fdfada8
description: Customers can use a shareable URL to access your B2B store. The shareable URL contains a special URL parameter that's associated with a buyer group that has its own price book and discounts. Customers who get to the store using the shareable URL are automatically assigned to the associated buyer group, either in addition to the buyer group the customer is already part of or instead of that buyer group, depending on how your developer set up buyer group extensions.
products:
  - Commerce
  - B2B Commerce
release: "264"
---
# Create a Shareable URL for Your Store

Customers can use a shareable URL to access your B2B store. The shareable URL contains a special URL parameter that's associated with a buyer group that has its own price book and discounts. Customers who get to the store using the shareable URL are automatically assigned to the associated buyer group, either in addition to the buyer group the customer is already part of or instead of that buyer group, depending on how your developer set up buyer group extensions.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=commerce.comm_editions.htm&amp;language=en_US" target="_blank">View supported editions</a>.</td></tr></tbody></table>

[Which Salesforce Commerce Product Do I Have?](https://help.salesforce.com/s/articleView?id=commerce.comm_what_product.htm&language=en_US)

A social media influencer can provide a shareable URL to their followers that gets the followers discounts on specific items. Similarly, if multiple distributors are selling products in your store, each distributor can have a shareable URL that assigns their customers to a specific buyer group that receives special discounts. To create a shareable URL, add a URL parameter to the markup in the store's heading.

When your developer configures buyer group extensions, the developer can specify what happens when a customer arrives at the store using a shareable URL. The shareable URL customer can be assigned to the buyer group associated with that shareable URL _along with_ the buyer group that was dynamically assigned. Alternatively, the shareable URL customer can be assigned to the buyer group associated with the shareable URL _instead of_ the buyer group that was dynamically assigned.

For example, consider a customer John Doe, who browses your store with the location set to US. You've set up special discounts on your store for Black Friday. Customers who have the store location set to US receive a special discount on all items in the store. John's son sends him an influencer's referrer link to the store. Anybody accessing the store through the link gets 10% off the price of certain items in the store. When John accesses your store using the link his son sent him, one of two things happen depending on how you set up the buyer group extension

- If the buyer group extension was set up such that the buyer group associated with the referrer URL overrides the dynamically assigned buyer groups (the buyer group based on location, for example), then John receives only the 10% discount on the price of certain items.
- If the buyer group extension was set up such that the buyer group associated with the referrer URL exists in addition to the dynamically assigned buyer groups, then John receives the 10%discount on certain items, as well as the Black Friday discounts you've set in place for your US store.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-commerce-comm-264-0-0-production-enus/d863e308-482a-4dfa-8d20-2a94737d394a/images/icon_note.png)

Note Salesforce recommends that you keep the number of characters in the URL parameter short so that your URL doesn't exceed the common browser limit of 2048 characters.

To implement a persistent URL, follow these steps.

1. In the navigation sidebar, select a store from the **Store** dropdown.
2. Click **Website Design** and then select **Experience Builder**.
3. In Experience Builder, click **Settings** | **Advanced**.
4. Click **Edit Head Markup**.
    
    ![Screenshot showing Edit Head Markup under Advanced Settings in Experience Builder](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-commerce-comm-264-0-0-production-enus/d863e308-482a-4dfa-8d20-2a94737d394a/comm/images/comm_shareableurl_expbuilder_advancedsettings.png)
5. Add the URL parameter to the existing markup.
    
    Faster Add-to-Cart supports only 20 parameters, with a maximum key length of 25 characters and a maximum value length of 251 characters. For more information about Faster Add-to-Cart, see [Improve Product Page Performance in a B2B Store](https://help.salesforce.com/s/articleView?id=commerce.comm_faster_add_to_cart.htm&language=en_US).
    
    For example, this sample markup code shows how to add a custom parameter `referrer`, in the URL.
    
    ```
    <script>
    window.CLWR = window.CLWR || {};
    window.CLWR.registeredPersistentParamNames = window.CLWR.registeredPersistentParamNames || new Set();
    
    // Register params
    window.CLWR.registeredPersistentParamNames.add("referrer");
    </script>
    ```
    
    The final markup looks like this.
    
    ![Screenshot showing head markup after edit.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-commerce-comm-264-0-0-production-enus/d863e308-482a-4dfa-8d20-2a94737d394a/comm/images/b2b_comm_sharableurl_markup.png)
6. Set the security level to **Relaxed CSP: Permit Access to Inline Scripts and Allowed Hosts**.
    
    ![Screenshot showing Relaxed CSP in the Advanced Security Settings in Experience Builder](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-commerce-comm-264-0-0-production-enus/d863e308-482a-4dfa-8d20-2a94737d394a/comm/images/comm_shareableurl_expbuilder_securitysettings.png)
    
    For more information, see [Select a Security Level in Experience Builder Sites](https://help.salesforce.com/s/articleView?id=experience.networks_security_csp_scriptlevel.htm&language=en_US).
7. Add an Apex extension that returns the buyer group for a user based on the URL parameter.
    
    When working with Apex, make sure that you follow the security tips for Apex development. For more information, see [Security Tips for Apex and Visualforce Development](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/pages_security_tips_intro.htm).
    
    For example, this custom code for the referral parameter`referrer` is linked to a referrer's username. The buyer group associated with the URL parameter is Discounted Buyer Group.
    
    ```
    if URL has parameter 'referrer':
         referrerUser = getUserByUsername(referrer)
         if referrerUser exists:
              assign shopper to Discounted Buyer Group
         else:
              assign shopper to Normal Buyer Group
    else:
         assign shopper to Normal Buyer Group
    ```
    
    If necessary, you can download a sample code, make the necessary changes, and then use the updated code for your store. See [Shareable URL sample](https://github.com/forcedotcom/commerce-extensibility/blob/main/commerce/domain/buyergroup/service/classes/BuyerGroupShareableURLSample.cls).
8. [Publish your store](https://help.salesforce.com/s/articleView?id=commerce.comm_publish_store.htm&language=en_US).