Secret link keys
In Locksmith, a "secret link" is a Shopify URL that contains a "secret code" on the end of it, like this:
When a locked resource has a secret link key, only visitors who arrive via that link will be able to view the resource. This makes secret links useful for secret sales, or for offering specific products that are only available via certain ad campaigns.
To configure a secret link, start by creating a lock. Then, in the lock settings, follow the prompts to create a secret link key:
Secret links consist of two parts:
- The secret link code (top box): This is the "secret" part of the link, which you can change to whatever you like.
- The full secret link (bottom box): This is the link you send your customers, or whoever should see the locked content. It's the regular URL for your locked content, with the secret link code appended to it. Click the copy button to copy to your clipboard.
Want your link code to be something different? You can simply change that, and it will update the full link:
Secret link formatting
It's important to note that the secret link code must be an exact match in order to work. If the customer accidentally adds a character to the end of that link, they won't get access.
Having said that, there is some flexibility on how the URL is constructed. The secret link code can be presented in several, valid ways, illustrated here:
Once a visitor arrives via a secret link, Locksmith will remember their access for a while. If you're testing, this can make it look like the key is no longer working. For more on this, see Why isn't my passcode, secret link, or newsletter key working?.
Re-using secret link codes
If you've got several secret link keys, across different locks, any keys that re-use the same secret code will all be activated when one link is used. This way, you can unlock several pieces of content across your store, using only a single secret link.
Using a vendor's referral link as a secret code
If you're using a referral service (or any other service that generates a URL with a specific code at the end), you can use the referral URL's "querystring" as the secret code for your key.
For example, if you're using a referral URL that looks like https://example.com/?rfsn=abc123, you may set your secret link code to "rfsn=abc123", and your Locksmith key will Just Work™.
Restricting where locked content is revealed
If your lock has been configured for resource hiding, the successful use of a secret link will reveal the hidden resource across your online store. If you'd like to make sure that your locked product (for example) can only ever be viewed on its product page, and never via store search or collection listings, add a second condition to your key which limits the key's usage to only the product page.
To do this, use the "and..." link next to your existing key, and select the "(custom Liquid)" option. Fill in the Liquid condition with request.page_type == "product", as shown below.
The result: your secret link key will continue to work normally, but the access afforded by the key will only work when the visitor is literally on a product page. This means that the key will not kick in when the visitor is (for example) looking at search results, which means that the product will remain hidden in those places.