Button Customization
Complete guide to customizing your virtual Try-On button with HTML attributes, styling, and dynamic data population.
Understanding the Button
The Try-On button is the trigger that opens your virtual try-on widget. It uses data attributes to pass product information to the widget.
Critical Requirement: The button MUST have the class trialclouds-trial-widget-trigger-button to function.
Required Button Attributes
These four attributes are mandatory for the widget to work:
data-product-id
Purpose: Unique identifier for the product
Format: String or number
Example:
data-product-id="SKU-12345"ordata-product-id="789"Used for: Analytics tracking, product identification
data-product-name
Purpose: Product title displayed in widget
Format: String (escape special characters)
Example:
data-product-name="Blue Cotton T-Shirt"Used for: Widget header, analytics
data-images
Purpose: Product images for try-on
Format: JSON array of image URLs
Example:
data-images='["https://example.com/img1.jpg","https://example.com/img2.jpg"]'Requirements:
Must be publicly accessible URLs
Use HTTPS (not HTTP)
Images should show model wearing product
Valid JSON format (use single quotes around attribute, double quotes inside)
data-link
Purpose: URL to product page
Format: Full URL
Example:
data-link="https://yourstore.com/products/blue-shirt"Used for: "Shop Now" link in widget, analytics
Minimal Button Example:
Optional Button Attributes
These attributes enhance functionality but aren't required:
data-brand
Purpose: Brand or vendor name
Example:
data-brand="Nike"Used for: Display in widget, analytics
data-price
Purpose: Original product price
Format: Numeric string (no currency symbols)
Example:
data-price="99.99"Used for: Display in widget, analytics
data-sale-price
Purpose: Discounted price (if on sale)
Format: Numeric string
Example:
data-sale-price="79.99"Used for: Shows sale price in widget
data-currency
Purpose: Currency code
Format: 3-letter ISO code
Example:
data-currency="USD","EUR","GBP","INR"Used for: Price display formatting
data-source
Purpose: Pre-loaded customer face image URL
Example:
data-source="https://example.com/customer-photo.jpg"Used for: Skip upload step for returning customers
Note: Use only if customer previously uploaded and you stored their image
data-user-id
Purpose: Customer identifier
Example:
data-user-id="customer_456"Used for: Analytics, tracking specific customers
data-user-name
Purpose: Customer's name
Example:
data-user-name="John Doe"Used for: Pre-filling widget forms, personalization
data-user-email
Purpose: Customer's email address
Example:
data-user-email="[email protected]"Used for: Pre-filling forms, follow-up
Full-Featured Button Example:
Button Text Customization
Change the button text to match your brand voice.
Examples:
Try On β Simple, clear
Try On π β With emoji
Virtual Try-On β Explicit
See It On You β Personal
Try Before You Buy β Value-focused
See How It Looks β Descriptive
Emoji Ideas: π π π π β¨ ποΈ π
Styling the Button
Inline CSS (Quick Method)
Pros: Quick, no separate CSS file needed Cons: Harder to maintain, can't use :hover without JavaScript
External CSS (Recommended)
Pros: Maintainable, supports hover/focus, can be reused Cons: Requires CSS file access
Adding CSS Classes
You can add additional classes for styling while keeping the required class:
Then style .my-custom-button in your CSS without affecting the widget functionality.
Responsive Design
Make your button mobile-friendly:
Mobile Best Practices:
Minimum height: 44px (Apple's tap target recommendation)
Full-width on mobile: Easier to tap
Larger font size: Better readability
Adequate padding: Comfortable tapping
Dynamic Data Population
JavaScript/React Example
WordPress/PHP Example
Multiple Buttons Per Page
You can have multiple Try-On buttons on the same page.
Use Case: Same Product, Multiple Locations
All buttons open the same product β customers can click whichever is most convenient.
Use Case: Different Products
Each button opens the widget with its respective product data.
Pre-filling Customer Data
If you have logged-in customers, pre-fill their information.
Benefits:
Faster experience for returning customers
Better analytics (track specific customers)
Personalization
Example with Conditional Logic (pseudo-code):
Security Note: Only use publicly available customer data. Never expose sensitive information (passwords, payment details, etc.).
Common Patterns
Pattern: Icon Button
Button with icon instead of text:
Pattern: Text + Icon
Pattern: Loading State
Show loading indicator while widget initializes:
Troubleshooting
Button Doesn't Trigger Widget
Check:
Class is exactly
trialclouds-trial-widget-trigger-button(no typos)Embed script is loaded (check
window.TrialClouds_APIin console)Required attributes present (product-id, product-name, images, link)
No JavaScript errors preventing click
Images Not Loading in Widget
Check:
URLs are publicly accessible (not localhost)
URLs use HTTPS (not HTTP)
data-imagesis valid JSON:'["url1","url2"]'Image files actually exist at those URLs
Button Styling Not Applied
Check:
CSS selector is correct and specific enough
No conflicting styles from theme
Browser cache cleared
CSS file is loaded before page render
Button Not Visible
Check:
Button HTML is present in page source (View Source)
No CSS hiding it (
display: none,visibility: hidden)Button isn't positioned off-screen
Check z-index if other elements cover it
Best Practices
Data Attributes
Always escape user-generated content
Validate URLs before inserting
Use proper JSON encoding for images array
Keep data minimal (don't send unnecessary info)
Accessibility
Use semantic
<button>element (not<div>or<a>)Ensure sufficient color contrast
Add focus styles for keyboard navigation
Consider aria-label for screen readers
Performance
Don't inline large images in data attributes
Use CDN URLs for product images when possible
Lazy load buttons if page has many products
Minimize DOM manipulation
Mobile
Make buttons touch-friendly (minimum 44x44px)
Test on actual devices, not just emulators
Consider thumb-reach zones for placement
Full-width buttons often work best on mobile
For platform-specific implementation:
Need help? Email [email protected]
Last updated