Redirect Membership Product
Automatically redirect visitors from the membership product page to your custom landing page.
Redirect customers who land on your membership product page to a dedicated landing page like /pages/rewards or /pages/vip. This provides a better experience than showing a standard product page.
Why Use This
- Better conversion: Landing pages convert better than product pages for memberships
- More information: Landing pages can showcase all membership benefits in detail
- Professional look: Avoid showing membership as a "product" with quantity selectors
- SEO flexibility: Keep your membership SEO on a custom page
Implementation
Create Your Landing Page
First, create a dedicated landing page in Shopify:
- Go to Online Store > Pages in Shopify admin
- Create a new page (e.g., "Rewards" or "VIP Membership")
- Design it to showcase your membership benefits
- Note the page URL (e.g.,
/pages/rewards)
Add the Redirect Code
Add this code to your theme. The best location is in snippets/product-form.liquid or wherever your product form is rendered, at the very top of the file:
{% assign current_variant_id = product.selected_or_first_available_variant.id %}
{% assign membership_variant_id = shop.metafields.exison.exison_plan_settings.product_variant_id.value | default: shop.metafields.exison.exison_plan_settings.product_variant_id %}
{% if current_variant_id == membership_variant_id %}
<script>
window.location.href = '/pages/rewards';
</script>
{% endif %}Change /pages/rewards to match your actual landing page URL.
Test the Redirect
- Visit your membership product page directly
- You should be immediately redirected to your landing page
- Verify the landing page loads correctly
- Verify the redirect doesn't happen for other products
How It Works
The code compares the current product variant ID with the membership variant ID stored in Subscribfy's metafields. If they match, it means the visitor is on the membership product page, and they get redirected to your landing page.
| Metafield | Description |
|---|---|
shop.metafields.exison.exison_plan_settings.product_variant_id | The Shopify variant ID of your membership product |
Alternative Placements
You can add this code in different locations depending on your theme:
| Location | When to Use |
|---|---|
snippets/product-form.liquid | Most themes - redirects before form renders |
sections/main-product.liquid | If your theme uses sections for product pages |
templates/product.liquid | Legacy themes without sections |
Place the code at the very top of the file, before any HTML output. This ensures the redirect happens immediately.
Troubleshooting
Redirect not working
- Verify the membership plan is configured and enabled in Subscribfy
- Place debug code before the
ifstatement to check the variant IDs:
{{ current_variant_id }}
{{ membership_variant_id }}Then refresh the page to see if the current_variant_id and membership_variant_id are the same. If they don't match, the redirect won't trigger.
Redirect loop
If you experience a redirect loop, make sure your landing page does not include the same product form snippet that contains the redirect code.
Want to keep the product page accessible
If you need the product page accessible for some users (e.g., for direct checkout links), you can add a URL parameter bypass:
{% unless request.path contains 'direct=true' %}
{% assign current_variant_id = product.selected_or_first_available_variant.id %}
{% assign membership_variant_id = shop.metafields.exison.exison_plan_settings.product_variant_id.value | default: shop.metafields.exison.exison_plan_settings.product_variant_id %}
{% if current_variant_id == membership_variant_id %}
<script>
window.location.href = '/pages/rewards';
</script>
{% endif %}
{% endunless %}Then access the product page directly via /products/membership?direct=true.
Was this page helpful?