Define where, when and whom to display the CMS blocks and pages with the Magento 2 Dynamic Blocks and Pages. Use your marketing campaigns with automation.
git clone https://github.com/magefan/magento-2-dynamic-blocks-and-pages.gitThe Magento 2 Dynamic Blocks and Pages skill allows users to define the conditions under which CMS blocks and pages are displayed. This automation skill is particularly useful for marketers looking to enhance their campaigns by targeting specific audiences at the right time and place. By utilizing this skill, users can streamline their marketing efforts, ensuring that relevant content reaches the intended audience without manual intervention. One of the key benefits of this skill is the potential for significant time savings. Although the exact time savings are not quantified, automating the display of CMS content reduces the need for manual updates and adjustments, allowing marketers to focus on strategy rather than execution. With an implementation time of just 30 minutes, users can quickly integrate this skill into their existing workflows, making it a practical choice for busy professionals. This skill is ideal for marketing professionals, product managers, and AI practitioners who are involved in campaign management and content strategy. By automating the display of CMS blocks and pages, teams can ensure that their marketing materials are always relevant and timely, which is crucial in today’s fast-paced digital landscape. For instance, a retailer could use this skill to display promotional banners only to users who have shown interest in specific products, thereby increasing conversion rates. With an intermediate level of complexity, this skill requires some familiarity with Magento 2 but is accessible for those with basic technical knowledge. It fits seamlessly into AI-first workflows by leveraging automation to enhance user engagement and improve marketing outcomes. By adopting the Magento 2 Dynamic Blocks and Pages skill, businesses can not only improve their marketing efficiency but also create a more personalized experience for their customers.
1. **Define Campaign Parameters:** Fill in [CAMPAIGN_NAME], [CUSTOMER_SEGMENT], and [COUNTRY/REGION] in the prompt. Use your Magento admin panel to verify customer segments and store views. 2. **Set Display Conditions:** Specify [DISPLAY_CONDITIONS] based on your marketing strategy (e.g., date ranges, page URLs, device types). Cross-check these with your Magento 2 backend settings under *Stores > Configuration > General > Content Management*. 3. **Design Content Elements:** Include [CONTENT_ELEMENTS] like banners, CTAs, or countdown timers. Use tools like Adobe Photoshop or Canva for visuals, then upload assets to Magento’s CMS media library. 4. **Configure Automation Rules:** Define [AUTOMATION_RULES] for personalization, A/B testing, or tracking. For personalization, use Magento’s *Customer Segments* feature. For A/B testing, enable *Magento Page Builder* or third-party extensions like Amasty’s A/B Testing. 5. **Generate and Deploy:** Copy the XML layout update code into your theme’s `default.xml` or a specific CMS page layout. Test the block/page in a staging environment before pushing to production. Use Magento’s *Cache Management* to clear static files after deployment.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/magefan/magento-2-dynamic-blocks-and-pagesCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Create a dynamic Magento 2 CMS block or page for [CAMPAIGN_NAME] targeting [CUSTOMER_SEGMENT] in [COUNTRY/REGION]. The block/page should display [PROMOTION_TYPE] with these conditions: [DISPLAY_CONDITIONS], and include [CONTENT_ELEMENTS]. Apply the following automation rules: [AUTOMATION_RULES]. Generate the XML layout update code and provide the block/page configuration details for a Magento 2 store.
For a **Summer Sale 2024** campaign targeting **new customers in the US and Canada**, we created a dynamic CMS block with the following specifications:
**Block Configuration:**
- **Block Title:** Summer Sale Hero Banner
- **Identifier:** summer_sale_2024_hero
- **Store Views:** English (US), English (Canada)
- **Customer Segments:** New Customers (First-time buyers)
- **Display Conditions:**
- Date Range: June 1, 2024 – August 31, 2024
- Page URLs: Homepage, Category Pages (Apparel, Accessories)
- Device: Desktop and Mobile
- Exclude logged-in returning customers
**Content Elements:**
- Full-width banner with gradient background (#FF6B35 to #F7931E)
- Headline: "Summer Sale: Up to 40% Off!"
- Subheadline: "Limited-time offer for new customers only."
- CTA Button: "Shop Now" (links to /summer-sale)
- Countdown timer: "Ends in [X] days, [X] hours"
**Automation Rules:**
1. **Personalization:** Show 20% discount for customers from California, 15% for others in the US/Canada.
2. **A/B Testing:** Rotate between two banner variants (Variant A: 40% off, Variant B: Free shipping + 30% off) with 50/50 split.
3. **Tracking:** Fire Google Analytics event `campaign_view` with parameters:
- `campaign_name`: summer_sale_2024
- `customer_segment`: new_customer
- `region`: [auto-detected from IP]
**XML Layout Update Code:**
```xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Cms\Block\Block" name="summer_sale_hero" before="-">
<arguments>
<argument name="block_id" xsi:type="string">summer_sale_2024_hero</argument>
</arguments>
</block>
</referenceContainer>
</body>
</page>
```
**Additional Notes:**
- The block will only appear for customers who haven’t made a purchase in the last 30 days.
- For logged-in customers, the system checks their `customer_group_id` to apply segment-specific discounts.
- The countdown timer updates every minute and resets at midnight UTC.
**Expected Outcome:**
This dynamic block is projected to increase new customer conversions by 12% and reduce cart abandonment by 8% during the campaign period, based on historical A/B test data from Q2 2023.Streamline talent acquisition with collaborative tools and customizable interview processes.
Automate your browser workflows effortlessly
Manage email lists and publish content in one place
Enterprise personalization platform
Build production-ready applications with AI.
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan