Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi, Since shopify have changed the checkout process I have been unable to get my opt-in to pop up. Does anyone have a solution for this issue that does not rely on apps?
Hi @jscicluna Modifying the checkout page directly is only possible through Shopify Plus.
You can place the opt-in on the cart page or use POP Up on the cart page.
Let me know which works for you so can assist you accordingly.
Dotsquares Ltd
Problem Solved? ✔ Accept and Like solution to help future merchants.
Hi @jscicluna ,
I am from Mageplaza - Shopify solution expert.
Shopify's recent checkout changes have introduced more restrictions on customization, making it trickier to integrate opt-in surveys. However, you can still achieve this without relying on third-party apps by leveraging Shopify's theme customizations, checkout extensibility (Shopify Plus), and Shopify Scripts (Shopify Plus only). Here are a few approaches:
1. Using a Custom Modal in Shopify Theme (Pre-Checkout)
If you want the opt-in survey before checkout, you can add a modal popup to your cart or product page using Liquid and JavaScript.
Steps:
Example Code (Add to cart.liquid or theme.liquid)
<div id="surveyModal" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5);">
<div style="background:#fff; padding:20px; margin:10% auto; width:300px; text-align:center;">
<p>Would you like to participate in our survey?</p>
<button id="yesBtn">Yes</button>
<button id="noBtn">No</button>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
setTimeout(() => {
document.getElementById("surveyModal").style.display = "block";
}, 2000); // Show modal after 2s
document.getElementById("yesBtn").addEventListener("click", function() {
fetch('/cart/update.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ attributes: { "Survey Opt-in": "Yes" } })
});
document.getElementById("surveyModal").style.display = "none";
});
document.getElementById("noBtn").addEventListener("click", function() {
document.getElementById("surveyModal").style.display = "none";
});
});
</script>
How it Works:
2.Adding the Survey to Checkout Page (Shopify Plus Only)
If you're on Shopify Plus, you can customize the checkout using Checkout UI Extensions and Shopify Functions.
Steps:
Example Checkout UI Extension (Shopify Plus)
import { reactExtension, useApplyAttributeChange } from "@shopify/ui-extensions-react/checkout";
export default reactExtension(
"purchase.checkout.block.render",
() => <SurveyOptIn />
);
function SurveyOptIn() {
const applyAttributeChange = useApplyAttributeChange();
return (
<div>
<p>Would you like to participate in our survey?</p>
<button
onClick={() => applyAttributeChange({ key: "Survey Opt-in", type: "updateAttribute", value: "Yes" })}
>
Yes
</button>
<button
onClick={() => applyAttributeChange({ key: "Survey Opt-in", type: "updateAttribute", value: "No" })}
>
No
</button>
</div>
);
}
How it Works:
3. Post-Checkout Survey (Order Confirmation Page)
If Shopify’s checkout restrictions block your opt-in, you can show a survey on the "Thank You" page.
Steps:
Example Script
<script>
document.addEventListener("DOMContentLoaded", function() {
let surveyResponse = prompt("Would you like to participate in our survey? (Yes/No)");
if (surveyResponse) {
fetch('/orders/{{ order.id }}/note.json', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ note: "Survey Opt-in: " + surveyResponse })
});
}
});
</script>
How it Works:
Final Thoughts
Would you like help refining this further?
Mageplaza | Top-Rated Shopify Agency | Trusted by 230,000+ worldwide merchants
If our suggestion works for you, please give it a Like or mark it as a Solution!
Should you have any questions or concerns, feel free to contact us via consultant@mageplaza.com
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025