How-to
How to Add an Apple Wallet Button Easily
By AddToWallet TeamPublished Updated 2 min read
Add a wallet button to a page you already have. In Safari the button says Add to Apple Wallet. In Chrome it says Add to Google Wallet.
1. Add a custom HTML block
Open the page where the button should appear and add a custom HTML block. WordPress, Wix, Squarespace, Weebly, and Shopify each include one.
2. Paste the snippet
Paste this snippet into the block. It chooses the badge from the browser.
<script>
window.onload = function() {
// Paste the pass link here in the button url string
const buttonUrl="https://app.addtowallet.co/card/........";
var button = document.getElementById("addToWalletButton");
var userAgent = window.navigator.userAgent;
var img = document.getElementById("walletImage");
if (userAgent.indexOf("Chrome") != -1 && userAgent.indexOf("Safari") != -1 && userAgent.indexOf("Edg") == -1) {
img.src = "https://s3.amazonaws.com/i.addtowallet.co/assets/Add_to_Google_Wallet_badge.svg.png";
} else if (userAgent.indexOf("Safari") != -1 && userAgent.indexOf("Chrome") == -1) {
img.src = "https://s3.amazonaws.com/i.addtowallet.co/assets/add_to_apple_wallet.png";
} else {
img.src = "https://s3.amazonaws.com/i.addtowallet.co/assets/Add_to_Google_Wallet_badge.svg.png";
}
button.style.background = 'none';
button.style.border='none';
button.style.width = '250px';
button.style.height = '72px';
img.style.width = '100%';
img.style.height = '100%';
button.style.cursor = 'pointer';
button.onmousedown = function() {
button.style.transform = 'scale(0.9)';
}
button.onmouseup = function() {
button.style.transform = 'scale(1)';
}
button.onclick = function() {
window.open(buttonUrl, '_blank');
}
}
</script>
<button id="addToWalletButton">
<img id="walletImage" src="" alt="addToWalletButton"/>
</button>
3. Replace the pass URL
Replace the buttonUrl string with the pass link. You can copy that link after creating a pass and clicking the copy icon.
Create Wallet Pass Now