Dynamic Member Experiences in Wix Studio: Personalizing Content by Age and User Attributes

As a Wix migration expert and community analyst, I frequently encounter discussions around creating highly tailored user experiences. A recent topic on the Wix Studio community forum, "Creating different experiences based on age, country & more," perfectly encapsulates the growing demand for personalization. The user, who has already successfully coded their custom member page (`www.site.com/personalpage`) to display the logged-in member's profile picture and name, seeks to take this a step further: dynamically altering the entire page's content—including writing style, images, pages, and links—based on the member's age group (baby, child, teenager, adult) selected during signup.

This challenge highlights a crucial aspect of modern web design: moving beyond static content to deliver truly relevant experiences. For store owners and developers on Wix Studio, leveraging Velo (Wix's powerful development platform) combined with Wix CRM capabilities is the definitive solution to this type of dynamic personalization.

The Core Challenge: Dynamic Content by User Attributes

The forum user's question boils down to conditional content rendering based on specific user attributes. They want a "child page" to differ significantly from an "adult member page" in terms of sophistication and displayed elements. While Wix Studio provides robust tools for member management, achieving this granular, attribute-based differentiation requires custom logic. The key is to capture relevant user data during the signup process and then use Velo to interpret that data and present a tailored experience on the custom member page.

The Velo Solution: Dynamic Content Rendering for Personalized Member Pages

The solution involves a systematic approach combining custom member fields, Wix CRM, and Velo coding. The general strategy is to:

  1. Capture User Attributes: Integrate custom fields into your signup flow to collect data like 'Age Group'.
  2. Store Data Securely: Ensure this collected data is properly stored within the Wix CRM, typically in the `Members` collection or a linked custom collection.
  3. Retrieve Data with Velo: On your custom member page, use Velo to fetch the logged-in user's data, including their custom attributes.
  4. Conditionally Render Content: Based on the retrieved attributes, use Velo to either show/hide different sections on the same page or redirect the user to a completely different dynamic page tailored to their profile.

Step-by-Step Implementation Guide

Step 1: Customizing the Signup Process and CRM Fields

  • Add Custom Fields: Navigate to your site's Dashboard > CRM > Member Signup Settings. Here, you can add custom fields to your signup form, such as a dropdown menu for "Age Group" with options like "Baby", "Child", "Teenager", "Adult".
  • Map Data to CRM: Ensure these custom fields are correctly mapped to your `Members` collection in the Wix CRM. This ensures the data is stored and accessible.

Step 2: Retrieving Member Data with Velo

On your custom member page, you'll use Velo to access the logged-in user's data, including the custom 'Age Group' field.


import wixUsers from 'wix-users';
import wixData from 'wix-data';

$w.onReady(function () {
    if (wixUsers.currentUser.loggedIn) {
        wixUsers.currentUser.getPrivateMembersData()
            .then((member) => {
                // Assuming 'ageGroup' is the key for your custom field
                const ageGroup = member.loginEmail.customFields.ageGroup; 
                
                // It's crucial to verify the exact path to your custom field.
                // Often, custom fields are directly under `member.customFields`
                // or within `member.loginEmail.customFields` depending on setup.
                // Console log `member` to find the correct path.
                console.log("Member Data:", member);
                console.log("Age Group:", ageGroup);

                if (ageGroup) {
                    personalizePage(ageGroup);
                } else {
                    console.warn("Age Group not found for this member.");
                    // Handle default experience or prompt user to update profile
                }
            })
            .catch((error) => {
                console.error("Error retrieving member data:", error);
            });
    } else {
        // Handle scenarios where the user is not logged in
        console.log("User not logged in. Redirecting to login or showing default content.");
        // Example: wixLocation.to('/login');
    }
});

function personalizePage(ageGroup) {
    // This function will contain the logic to display content based on ageGroup
    console.log("Personalizing content for age group:", ageGroup);
    // ... more code to follow ...
}

Step 3: Implementing Dynamic Content Display

There are two primary methods for displaying dynamic content:

Option A: Conditional Section Visibility on a Single Page

This method involves creating different sections (e.g., using `Box` or `Section` elements) in the Wix Studio editor for each age group. You then hide all of them by default and use Velo to show only the relevant section.

  • Editor Setup: Design distinct sections on your `personalpage` for Adults, Children, Teenagers, etc. Give them unique IDs (e.g., `#adultContentBox`, `#childContentBox`). Ensure they are initially hidden in the editor's properties panel.
  • Velo Logic:

function personalizePage(ageGroup) {
    // Hide all content boxes first
    $w("#adultContentBox").hide();
    $w("#childContentBox").hide();
    $w("#teenagerContentBox").hide();
    // Add more boxes as needed

    switch (ageGroup) {
        case 'Adult':
            $w("#adultContentBox").show();
            // You can also dynamically update text, images, links within this box
            $w("#adultTitle").text = "Welcome, Valued Adult Member!";
            $w("#adultImage").src = "wix:image://v1/adult-banner.jpg";
            break;
        case 'Child':
            $w("#childContentBox").show();
            $w("#childTitle").text = "Hello, Young Explorer!";
            $w("#childImage").src = "wix:image://v1/child-banner.jpg";
            break;
        case 'Teenager':
            $w("#teenagerContentBox").show();
            $w("#teenagerTitle").text = "Hey, Future Innovator!";
            $w("#teenagerImage").src = "wix:image://v1/teen-banner.jpg";
            break;
        case 'Baby':
            // Implement content for babies (parents' view)
            break;
        default:
            // Show a default experience or an error message
            console.warn("Unknown age group. Displaying default content.");
            $w("#defaultContentBox").show(); // Assuming a default box exists
            break;
    }
}

Option B: Redirection to Dynamic Pages

For more complex or structurally distinct experiences, creating separate dynamic pages for each age group offers better organization.

  • Wix CMS Setup: Create a collection in Wix CMS (Content Manager) for your member page variations (e.g., "MemberPagesConfig"). Include fields like `ageGroup` (Text), `pagePath` (Text), `pageTitle` (Text), etc.
  • Dynamic Pages: Create dynamic pages based on this collection (e.g., `/personalpage/{ageGroup}`).
  • Velo Logic:

import wixLocation from 'wix-location';

function personalizePage(ageGroup) {
    let redirectPath = "/personalpage"; // Default path

    switch (ageGroup) {
        case 'Adult':
            redirectPath += "-adult"; // Or use a slug from CMS: `/personalpage/adult`
            break;
        case 'Child':
            redirectPath += "-child";
            break;
        case 'Teenager':
            redirectPath += "-teenager";
            break;
        case 'Baby':
            redirectPath += "-baby";
            break;
        default:
            console.warn("Unknown age group. Redirecting to general page.");
            // Perhaps redirect to a generic member page or an error page
            break;
    }
    
    // Prevent unnecessary redirects if already on the correct page
    if (wixLocation.path !== redirectPath && wixLocation.path !== redirectPath + '/') { 
        wixLocation.to(redirectPath);
    }
}

Step 4: Managing Content for Different Experiences

Regardless of whether you use conditional sections or dynamic pages, managing the actual content (text, images, links) for each age group is critical:

  • Wix CMS: Utilize the Wix CMS to store all your content. Create separate collections or add fields to existing ones to hold content specific to each age group. This centralizes content management and makes updates easier.
  • Dataset Integration: Link elements on your pages to CMS items via datasets, filtering the dataset based on the `ageGroup` to display relevant content. For more complex scenarios, fetch data directly using `wixData.query` in Velo.

Advanced Considerations & Best Practices

  • Security for Age-Gating: For truly sensitive content (e.g., alcohol, mature themes) where age verification is legally mandated, client-side Velo alone is not sufficient. Implement server-side checks using Velo backend functions to validate age before granting access to specific content or pages.
  • User Experience: Ensure smooth transitions between personalized content. Provide clear navigation and consider a default or fallback experience if age group data is missing or invalid.
  • Scalability: For a large number of personalization attributes (e.g., age, country, interests, membership level), a data-driven approach using Wix CMS collections and dynamic pages (Option B) is generally more scalable and manageable than complex conditional logic on a single page.
  • Maintainability: Keep your Velo code well-organized, commented, and modular. Use functions to encapsulate specific logic, making it easier to debug and update.

Conclusion

The forum user's aspiration to create a highly personalized website experience based on attributes like age is not just achievable but essential for modern web engagement. By strategically combining Wix Studio's robust platform, custom CRM fields, and the power of Velo, store owners and developers can implement dynamic content rendering that significantly enhances user relevance and satisfaction. Whether through conditional section visibility or intelligent redirection to dynamic pages, the tools are readily available to transform a generic website into a uniquely tailored journey for every member.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools