Custom domains allow you to display your digital wallet passes on your own domain, providing a seamless, branded experience for your users. This guide will walk you through the entire process of setting up custom domains and integrating the AddToWallet SDK into your website.
Custom domains in AddToWallet enable you to host your digital passes on your own website domain instead of using the default AddToWallet URLs. This feature is available for Small Business and Enterprise plan users and provides several benefits:
Before you begin, ensure you have:
https://yourdomain.com/passes)Log in to your AddToWallet account and navigate to the Settings section. Look for the Custom Domain or Custom Pass Share URL option.
Screenshot of the AddToWallet Custom Domain settings, showing an entered domain and enabled SDK integration.
In the Custom Domain settings:
https://yourdomain.com/preview)http:// or https://)Note: Make sure your custom domain is properly configured and accessible. The URL should be publicly reachable for the integration to work correctly.
Screenshot of the AddToWallet SDK integration code section.
After setting your custom domain:
First, you need to include the AddToWallet SDK script in your website. Add this script tag to the <head> section of your HTML file:
<script src="https://app.addtowallet.co/lib/addtowallet-sdk-minified-v1.0.0.js"></script>
Next, create a container element where the wallet widget will be displayed. Place this <div> where you want the pass to appear on your page:
<div id="add-to-wallet-container"></div>
Finally, initialize the SDK widget by adding this script before the closing </body> tag. Replace "your-pass-slug-here" with your actual pass slug:
<script>
document.addEventListener("DOMContentLoaded", function() {
// Create a new wallet widget
const widget = AddToWalletSDK.create(
"add-to-wallet-container",
"your-pass-slug-here",
{
// Add any additional options here
}
);
});
</script>
Important: Replace "your-pass-slug-here" with your actual pass slug. You can find your pass slug in the AddToWallet dashboard when viewing or editing your pass.
The AddToWallet SDK supports various configuration options to customize the widget's appearance and behavior. Here are the available options:
{
// Dimensions and Styling
width: "100%", // Width of the widget
height: "600px", // Height of the widget
borderRadius: "12px", // Border radius of the widget
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)", // Box shadow
minHeight: "400px", // Minimum height
maxHeight: "800px", // Maximum height
padding: "0px", // Padding inside the widget
margin: "0px", // Margin around the widget
backgroundColor: "#ffffff", // Background color
zIndex: 1000, // Z-index of the widget
// Spinner Options
showSpinner: false, // Show loading spinner
spinnerColor: "#007AFF", // Spinner color
spinnerSize: "40px", // Spinner size
// Behavior and Callbacks
retryAttempts: 3, // Number of retry attempts
retryDelay: 2000, // Delay between retries (ms)
timeout: 30000, // Timeout for loading (ms)
// Event Callbacks
onLoad: function() {
console.log("Widget loaded successfully!");
},
onError: function(error) {
console.error("Widget error:", error);
},
onWalletClick: function(wallet) {
console.log("User clicked on:", wallet);
},
onResize: function(dimensions) {
console.log("Widget resized:", dimensions);
},
onRetry: function(attempt) {
console.log("Retrying attempt:", attempt);
},
logEvent: function(eventName, eventData) {
console.log("Event:", eventName, eventData);
}
}
Here's a complete example of an HTML page that integrates the AddToWallet SDK:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AddToWallet Custom Domain Integration Example</title>
<!-- Add the SDK script to your website -->
<script src="https://app.addtowallet.co/lib/addtowallet-sdk-minified-v1.0.0.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f5f5f5;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333;
margin-bottom: 10px;
}
#add-to-wallet-container {
margin: 20px 0;
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to Our Custom Domain Page!</h1>
<p>This is an example page demonstrating the AddToWallet SDK integration on a custom domain.</p>
<h2>Your Digital Pass</h2>
<!-- Create a container for the widget -->
<div id="add-to-wallet-container"></div>
<h2>More Content</h2>
<p>Feel free to add more content here. The AddToWallet widget above will display your digital pass directly on your website.</p>
</div>
<!-- Initialize the SDK -->
<script>
document.addEventListener("DOMContentLoaded", function() {
// Replace 'your-pass-slug-here' with your actual pass slug
const widget = AddToWalletSDK.create(
"add-to-wallet-container",
"your-pass-slug-here",
{
width: "100%",
minHeight: "500px",
borderRadius: "12px",
showSpinner: true,
spinnerColor: "#007AFF",
onLoad: function() {
console.log("Wallet widget loaded successfully!");
},
onError: function(error) {
console.error("Error loading widget:", error);
alert("Failed to load wallet widget. Please try again later.");
},
onWalletClick: function(wallet) {
console.log("User clicked on:", wallet);
}
}
);
});
</script>
</body>
</html>
After integrating the SDK:
If you encounter issues:
Congratulations! You've successfully integrated custom domains and the AddToWallet SDK into your website. Your users can now add digital passes directly from your domain, providing a seamless and branded experience.
For more information and advanced customization options, visit the AddToWallet API Documentation.
Get Started For Free
Free Templates
Edit Multiple Pass
View Pass Usage Stats
Join the expanding network of more than 10k+ users
No credit card needed to start trial
addtowallet.co © All Rights Reserved
