In this article, I'll be going over how you can use an Iterable Snippet to create passes for your users on the fly with PassKit SmartPass links.
If you want to learn more about SmartPass links, you can find more information here.
To get started, log in to the PassKit portal and navigate to the Membership Program you will be enrolling users into.
If this is your first time issuing passes from a Snippet, we recommend using a Draft program. Passes issued in a Draft program do not contribute to your monthly bill from PassKit.
Once there, click the Distribution header link, then the Pre-Generated Links option.
On the next page, click the "Command Line Tools" tab on the right. Copy the PassKit URL and the Project Secret.
Now you can head over to Iterable. The first thing we need to do is configure your HMAC secret so we can create secure SmartPass links. Once you have logged into Iterable, click the settings icon in the top right and select Project Settings from the dropdown.
Inside the Project Settings page, scroll down to the HMAC Secret input field and paste in the Project Secret you copied earlier from PassKit.
Scroll down to the bottom and save your settings.
This secret will be used to enhance the security of the SmartPass links you send to your users.
Next, we need to create a Snippet. If you don't know what a Snippet is, have a look at Iterable's documentation before reading further.
You can create a Snippet by clicking the Content tab on the home page and selecting Snippets.
Once you are on the Snippets page, click the New Snippet button in the top right. Once inside the Snippet creator, give your snippet a name. After that, scroll down and select the Source button in the Editor.
With Source selected, paste this block into the editor:
{{#assign "url"}} your_url_here {{/assign}}
{{#assign "link"}} {{url}}?data={{#base64}} { "members.member.externalId": "{{email}}" } {{/base64}} {{/assign}}
<a href="{{link}}&sig={{ hmacSHA1 link }}">Click Here For Your Pass</a>
Replace your_url_here
with the PassKit Url from before. This block will create a hashed smartpass link on the fly when you send an email to a customer.
This code block includes a minimum example of the fields that PassKit will need to create a Pass. { "members.member.externalId": "{{email}}" }
You can add in any supporting fields to further personalize your membership cards. A list of all PassKit's SmartPass fields can be found here.
Once your code block is set up, let's test it out. Paste your Snippet identifier into a test template. If you are unsure about how to create a template, please read through this template overview.
Preview the template with data. Make sure that you load user data, the Snippet requires at least an email to work.
You should see something like this:
Click the link in the preview and you should see the preview redirect to a PassKit pass landing page.
At this point, you have issued a pass that can be seen inside the PassKit portal.
If you want to test again, you'll need to use another email or delete the membership record in PassKit.