- Help Center
- Configuration
- Redirects
-
Getting Started
-
Configuration
- Targeting
- Split URL
- Product Testing
- Full Stack
- Experiment Management
- CSP Configuration
- Experiment Execution
- Reports
- Exit Popups
- GTM Integration
- Troubleshooting
- Performance Optimization
- Event-Triggered Changes
- Holdout Groups
- Split URL Pages
- URL Parameters
- DataLayer
- Menu Configurations
- Traffic Exclusion
- Experiment Scheduling
- Dynamic Element Changes
- Price Targeting
- Experience Scheduling
- Privacy
- Hash Changes
- Async Tracking
- Selective Installation
- CSS Selectors
- Vue.js Integration
- Page Content
- Multipage Split URL
- Organic Traffic
- Visual Editor
- Server-Side Testing
- Traffic Bucketing
- GDPR Warnings
- Statistical Confidence
- Browser Privacy
- Query Parameters
- Embedded Videos
- Tracking Code Execution
- Simultaneous Experiments
- Tags
- Deployments
- Disable Testing
- Locations
- Programmatic Bucketting
- Query Parameter Handling
- Convert Library
- Variation Previews
- Experiment Editing
- Opt-Out Script
- Data Reset
- Body Hiding
- Visit-Specific Variations
- Variation Styling
- Preview Issues
- Variation Editing
- Full-Site Testing
- Blinking Variations
- Cross-Domain Cookies
- Regex Support
- Conversion Tracking
- SPA Testing
- Project Setup
- Cross-Domain Tracking
- Geo-Targeting
- Analytics Tools
- Campaign Tags
- Previewing
- IDs
- Query String Targeting
- Bounce Rate Goals
- Bot Filtering
- Query String Variables
- Custom Audiences
- Redirects
- Baseline
- Tracking Code Location
- Secure Cookies
- AngularJS
- Cloudflare
- Code Installation
-
Track Goals
- Form Tracking
- Cookie Management
- iFrame Click Tracking
- Performance Optimization
- Revenue Tracking
- Interaction Goals
- Form Submissions
- Advanced Goals
- Lazy Loading
- Multi-Conversions
- URL Parameters
- Bounce Rate Goals
- DataLayer Integration
- Scroll Depth
- Social Interactions
- Page Views
- Marketo Forms
- Feature Analysis
- AJAX Forms
- Revenue Tracking via GTM
- Order Outliers
- Cumulative Revenue
- Goal Templates
- Adding Revenue Goals
- JS-Based Goals
- Goal Basics
- Google Analytics Goals
- Social Sharing
- Dynamic Goals
- Typeform Integration
-
Target Visitors
- Geolocation
- Interaction Goals
- Goal-Based Targeting
- Weather Targeting
- Cookie-Based Targeting
- Page Visits
- Audience Management
- Audience Segmentation
- Experiment Targeting
- Advanced Audience Creation
- Audience Templates
- Audience Creation
- Data Layer Integration
- Manual Activation
- JavaScript Conditions
- Device Targeting
- Language Targeting
- IP-Based Exclusion
- Visitor Management
- Page Tagging
- Cookies
-
Troubleshooting
- Google Warnings
- Visual Editor
- HTTPS Content
- Logs
- Support Options
- Bootstrap
- Cookie Blocking
- Change History
- Mobile Debugging
- AdWords
- Bot Exclusion
- Domain Issues
- Cloudflare Issues
- Monitoring
- Cloaking Penalties
- Goal Editor Issues
- Variations
- Snippet Performance
- Changes Not Saved
- Blocked Visual Editor
- Goal Testing
- Visual Editor Browsing
- Experiment Issues
- Installation Verification
- Data Leak Prevention
- Usage Limits
- Experiment Previews
- GA4 Revenue
- Chrome Debugger Logs
- SPA Errors
- Checkout JSON Error
-
Analyze Results
-
Integrations
- Google Analytics
- Cookie Consent Platforms
- Microsoft Clarity
- Plausible
- Marketo
- HubSpot
- Tealium
- Smartlook
- Klaviyo
- Salesforce CRM
- FullStory
- Snowplow Analytics
- Webflow
- GA4 Roles
- Amplitude
- Segment
- React
- BigCommerce
- WooCommerce
- Active Campaign
- Google Tag Manager
- Mixpanel
- Zapier
- Inspectlet
- Crazy Egg
- LanderApp
- Unbounce
- Instapage
- Drupal
- PrestaShop
- Magento
- Roistat
- Piano Analytics
- Heap Analytics
- Kissmetrics
- Mouseflow
- Adobe Analytics
- Clicky
-
Account Management
-
Developers
-
What's New
-
Common Questions
-
Shopify
How Do I Create a Variation that Redirects to Another Page Based on Certain Logic?
THIS ARTICLE WILL HELP YOU:
- Understand Redirect Logic
- Adding Variation Code or Variation Custom Javascript
- Passing Convert Cookie Data for cross-domain tracking.
Understand Redirect Logic
Sometimes you might need to make your A/B experiment's variations redirect to another page based on some logic. Of course, you could just start writing your JS code that redirects to the new page but the problem is just half solved.
Doing that will result in your variation not recording any stats since it redirects before allowing for the stats to be stored.
To fix that, we introduced a JS function that you can use to redirect to another page, without losing the ability to also store stats for that specific variation:
convert.redirect("URL_here");
So, instead of using for example:
document.location.href="http://www.mysite.com/my_variation_page.html"
Use the following, instead:
convert.redirect("http://www.mysite.com/my_variation_page.html");
Note: The above code has to be used only inside the "Custom Javascript" section inside the visual editor:
If you need to transfer the query parameters, then you need to use this:
function redirectToNewUrlWithParam() {
// Get the current URL
var currentUrl = window.location.href;
// Check if the URL already has query parameters
if (currentUrl.includes('?')) {
// If yes, append the new parameter with an ampersand
currentUrl += '&ft=04nf23r';
} else {
// If no, append the new parameter with a question mark
currentUrl += '?ft=04nf23r';
}
// Redirect to the new URL
convert.redirect(currentUrl);
}
redirectToNewUrlWithParam();
Adding Variation Code or Variation Custom Javascript
If you need to also change the styling of the variation pages where you are redirecting your visitors, you will need to create a deploy for each of the variation URLs where you are redirecting them, and implement the changes on the deploy.
Important
Do not include the variation changes on the same experiment where you used the convert.redirect() instruction, as this will lead to invalid experiment data.
Passing Convert Cookie Data for cross-domain tracking.
If your second-page domain is in a separate domain, the cookie data is passed automatically to the second domain.