Form Features
Country & Redirect Controls
Country Disable
The CountryDisable component allows you to remove specific countries from country dropdown lists, preventing users from selecting them.
Tip!
If you are looking to restrict your form to only users in the United States, consider using the UsOnlyForm component
Overview
Use this to restrict form submissions to specific countries or exclude countries where your organization doesn't operate.
Configuration
Configure via EngridOptions:
EngridOptions = {
CountryDisable: ["US", "CA", "GB"]
};
Or use country names:
EngridOptions = {
CountryDisable: ["United States", "Canada", "United Kingdom"]
};
You should know!
The component matches both country codes (US, CA) and country names (United States, Canada), and is case-insensitive.
Affected Fields
The component removes countries from these field types:
supporter.country- Primary country fieldtransaction.shipcountry- Shipping countrysupporter.billingCountry- Billing countrytransaction.infcountry- Additional info country
How It Works
// Finds all country dropdowns
const countries = document.querySelectorAll(
'select[name="supporter.country"], select[name="transaction.shipcountry"]...'
);
// Removes matching options
option.remove();
Debug Logging
Enable debug mode to see which countries are being removed:
EngridOptions = {
debug: true,
CountryDisable: ["US"]
};
Look for [🌎 CountryDisable] in console showing:
Removing United States from supporter.country
Examples
Block specific countries:
EngridOptions = {
CountryDisable: ["GB","FR"] // Great Britain, France
};
Mix codes and names:
EngridOptions = {
CountryDisable: ["US", "United Kingdom", "CA", "France"]
};
Best Practices
- Use Country Codes: More reliable than names (2-letter ISO codes)
- Test Thoroughly: Verify correct countries are removed
- Consider EN Settings: EN has built-in country restrictions you may prefer
- Legal Compliance: Ensure restrictions comply with your organization's policies
- Communication: Clearly communicate country restrictions to users
Country Redirect
The CountryRedirect component automatically redirects users to different pages based on their selected country, enabling region-specific donation flows.
Overview
When users select a specific country, they're automatically redirected to a country-specific page. Perfect for:
- Multi-currency campaigns
- Regional organizations
- Localized content
Configuration
Configure via CountryRedirect in your client theme:
...
CountryRedirect: {
US: "https://example.org/us-donation",
CA: "https://example.org/canada-donation",
GB: "https://example.org/uk-donation",
AU: "https://example.org/australia-donation"
}
...
Page-Level Configuration
Override for specific pages using a code block:
<script>
window.EngridPageOptions = window.EngridPageOptions || {};
window.EngridPageOptions.CountryRedirect = {
US: "https://example.org/us-regional",
CA: "https://example.org/ca-regional"
};
</script>
This overrides the default CountryRedirect options for that page only.
How It Works
- User selects a country from dropdown
- Component checks if country is in
CountryRedirectobject - Verifies current URL is different from target URL (prevents redirect loops)
- Adds
?chainparameter if not present - Redirects user to specified URL
Chain Parameter
The component automatically adds the ?chain parameter to preserve form data:
// If redirect URL doesn't have ?chain, adds it
if (!redirectUrl.search.includes("chain")) {
redirectUrl.search += (redirectUrl.search ? "&" : "?") + "chain";
}
This ensures the user's information follows them to the regional page.
Country Codes
Use 2-letter ISO country codes that match EN's country field values:
- US - United States
- CA - Canada
- GB - United Kingdom
- AU - Australia
- DE - Germany
- FR - France
- etc.
When Redirect Occurs
Redirects when:
- Country matches one in
CountryRedirectobject - Target URL is different from current URL
- Country field exists on page
Does NOT redirect when:
- Already on the target URL (prevents loops)
- Country not in
CountryRedirectobject - No country field on page
Debug Logging
Enable debug mode to see redirect activity:
EngridOptions = {
debug: true,
CountryRedirect: { /* config */ }
};
Look for [🛫 CountryRedirect] in console showing:
US: Redirecting to https://example.org/us-donation?chain
You may need to check "Persist Logs" to see the log print even after the page is redirected.
Use Cases
1. Tax-Deductible Entities:
// Redirect to appropriate charity registration
CountryRedirect: {
US: "https://us-charity.org/donate", // 501(c)(3)
CA: "https://ca-charity.org/donate", // Registered charity
UK: "https://uk-charity.org/donate" // Registered charity
}
2. Currency-Specific Pages:
// Each page shows appropriate currency
CountryRedirect: {
US: "https://example.org/donate?currency=USD",
GB: "https://example.org/donate?currency=GBP",
EU: "https://example.org/donate?currency=EUR"
}
3. Regional Organizations:
// Different offices handle different regions
CountryRedirect: {
US: "https://us.organization.org/donate",
CA: "https://canada.organization.org/donate",
AU: "https://australia.organization.org/donate"
}
Best Practices
- Prevent Loops: Ensure regional pages don't redirect back
- Test Chain Parameter: Verify form data carries through redirects
- Clear Communication: Inform users why they're being redirected
- Use 2-Letter Codes: Match EN's country field format exactly
- Consider UX: Don't redirect after user has filled extensive form data
- Mobile Testing: Ensure redirects work smoothly on mobile devices
- Analytics: Track redirects to understand regional traffic patterns
Troubleshooting
Not redirecting:
- Verify country code matches EN's format exactly
- Check if already on target URL (prevents loops)
- Ensure country field exists on page
- Look for console errors
- Enable debug mode to see redirect attempts
Redirect loops:
- Ensure target page doesn't have same
CountryRedirectconfig - Check if URL comparison is failing
- Verify URL string matching is working correctly
Lost form data:
- Confirm
?chainparameter is being added - Test that EN's chain feature is working
- Verify regional page has same field names
Regional Campaign Strategy
Common Patterns
Global Hub → Regional Pages:
- Create a global landing page without
CountryRedirect - Use
CountryRedirectto send users to regional pages - Regional pages don't have
CountryRedirect(end of chain)
Regional Page → Regional Thank You:
- Regional donation page redirects based on country
- Each region has its own thank you page
- Thank you pages show region-specific impact
Multi-Step with Country:
- Page 1: Collect basic info + country
- Redirect to regional page 2 via
CountryRedirect - Page 2: Regional payment processing
- Page 3: Regional thank you
Integration with Other Components
- Auto Country Select: Detects location, works with redirect
- Custom Currency: Each regional page can have different currency
- Translation: Regional pages can be in local languages
US Only Form
The US Only Form component is a specific use case of country redirect that automatically sets the country to "United States" and hides the country field, ensuring only US supporters can submit the form. It also notices non-US users to with a warning banner.