1.a iFrame embed
Learn how to embed the Loyalty Microsite in a website using an iFrame, manage authentication, configure permissions, and handle dynamic content height adjustments for seamless integration.
Embed the Loyalty Microsite in a website
Embedding the Loyalty Microsite in a website via an iFrame provides a seamless way to integrate WLL’s loyalty features directly into an existing webpage, allowing users to interact with the loyalty program without leaving your site. Here’s how to set up and configure the microsite in an iFrame.
Handling user authentication
Requesting a Session Token: Make a secure HTTP request from your server to the microsite’s authentication endpoint, as outlined in 2. Microsite authentication. This ensures that your “Client ID” remains protected.
Passing the Session Token: Pass the returned session token to the microsite within the iFrame by using a session query parameter or as a session cookie.
Using a session query parameter
Append the microsite URL with ?session=$sessionToken.
Using cookies
If using cookies, ensure the user’s browser receives the session cookie before loading the iFrame:
From the Browser Context: The endpoint will automatically set the cookie.
From the Server Context: The “Set-Cookie” header in your response should forward to the browser, or you can construct the cookie as explained in 2. Microsite authentication.
To ensure authentication functions correctly across all browsers, ensure the 3. Custom domain configured for your microsite matches that of the webpage hosting the iFrame.
Configuring the iFrame
Add an iFrame element on your webpage pointing to the microsite’s root URL, for example:
iFrame permissions
To enable location services (for reward redemption and receipt upload) and clipboard access (for email receipt uploads and refer-a-friend URL copying), add the following attributes to the <iframe> tag:
iFrame postMessage communication
When embedded in an iFrame, the Loyalty Microsite uses the postMessage() feature to communicate with the iFrame parent window. You can use these messages to respond to navigation changes or dynamically adjust the iFrame’s height.
FAQs
Is it possible to load specific pages of the microsite directly in an iFrame?
Yes, you can add URL parameters to load specific microsite pages. For example, to load the Activity page, modify the iFrame src URL to include redirect_path=/activity (e.g., https://MICROSITEURL.COM?redirect_path=/activity).
What if my iFrame content height changes dynamically?
Use the postMessage() feature to handle dynamic height changes. The microsite sends a RESIZE_BODY message when the content height changes, allowing your iFrame to adjust its height based on the contentHeight value provided.
Last updated
Was this helpful?