# URL State Example - Navigation Flow ## πŸ“ Visual Journey Through URL Changes ### Step 1: Page Load ``` URL: https://yoursite.com/ State: Fresh start, no parameters Bit Value: 0 ``` ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ What are you looking for? β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ πŸšͺ β”‚ β”‚ πŸͺŸ β”‚ β”‚ β”‚ β”‚Door β”‚ β”‚Windowβ”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ### Step 2: User Selects "Door" ``` URL: https://yoursite.com/?b=1&q=q-door-type ↑ Bit 0 set (Door) State: Door selected Bit Value: 1 (binary: 1) Bits Active: Door ``` ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ What type of door? β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚Storm Doorβ”‚ β”‚Patio Doorβ”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ### Step 3: User Selects "Storm Door" ``` URL: https://yoursite.com/?b=16385&q=q-material-storm-door ↑ 16385 = 1 (Door) + 16384 (Storm Door) State: Door + Storm Door selected Bit Value: 16385 (binary: 100000000000001) Bits Active: Door, Storm Door subtype Calculation: Bit 0 (Door) = 1 Bit 14 (Storm Door)= 16384 Total = 16385 ``` ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Select Material β”‚ β”‚ CONDITIONAL: Only showing β”‚ β”‚ because some storm doors have β”‚ β”‚ multiple materials β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚Aluminum β”‚ β”‚ Vinyl β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ### Step 4: User Selects "Aluminum" ``` URL: https://yoursite.com/?b=16401&q=q-color-storm-door ↑ 16401 = 1 + 16 + 16384 State: Door + Aluminum + Storm Door Bit Value: 16401 (binary: 100000000010001) Bits Active: Door, Aluminum, Storm Door subtype Calculation: Bit 0 (Door) = 1 Bit 4 (Aluminum) = 16 Bit 14 (Storm Door)= 16384 Total = 16401 ``` ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Select Color β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Black β”‚ β”‚ White β”‚ β”‚Bronze β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ### Step 5: User Selects "White" ``` URL: https://yoursite.com/?b=16529&q=q-dimensions ↑ 16529 = 1 + 16 + 128 + 16384 State: Door + Aluminum + White + Storm Door Bit Value: 16529 (binary: 100000010010001) Bits Active: Door, Aluminum, White, Storm Door Calculation: Bit 0 (Door) = 1 Bit 4 (Aluminum) = 16 Bit 7 (White) = 128 Bit 14 (Storm Door)= 16384 Total = 16529 ``` ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Enter Dimensions β”‚ β”‚ Width: [______] inches β”‚ β”‚ Height: [______] inches β”‚ β”‚ [Continue β†’] β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ### Step 6: View Results ``` URL: https://yoursite.com/?b=16529&q=results State: Showing filtered products Bit Value: 16529 Products Matched: All doors that are: βœ“ Storm Door type (bit 14) βœ“ Aluminum material (bit 4) βœ“ Available in White (bit 7) ``` ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Found 3 Products β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ STAR 6100 FULL VIEW β”‚ β”‚ β”‚ β”‚ Code: 6100I β”‚ β”‚ β”‚ β”‚ Aluminum, White, Bronze β”‚ β”‚ β”‚ β”‚ [View Details] β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ COLUMBIA COBRA β”‚ β”‚ β”‚ β”‚ Code: COBRAI β”‚ β”‚ β”‚ β”‚ [View Details] β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ### Step 7: Click Product Detail ``` URL: https://yoursite.com/?p=6100I&b=16529 ↑ Product code added State: Viewing specific product 6100I Bit Value: 16529 (preserved for "back" navigation) ``` ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ STAR 6100 FULL VIEW STORM DOOR β”‚ β”‚ ────────────────────────────────── β”‚ β”‚ Product Code: 6100I β”‚ β”‚ Category: STD β”‚ β”‚ Materials: Aluminum β”‚ β”‚ Colors: White, Bronze β”‚ β”‚ β”‚ β”‚ Compatible Accessories: β”‚ β”‚ β€’ BGIST - Inserts for Storm Doors β”‚ β”‚ β€’ TGIODD - Top Glass Inserts β”‚ β”‚ β”‚ β”‚ [← Back] [Start Over] [πŸ”— Share] β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ### Step 8: Copy & Share URL ``` User clicks "πŸ”— Share" button Copies: https://yoursite.com/?p=6100I&b=16529 Someone else pastes this URL in their browser: β†’ Instantly shows product 6100I β†’ Navigation state preserved (b=16529) β†’ Back button navigates through original path ``` --- ### Step 9: Browser Back Button ``` User clicks browser back button URL Changes: https://yoursite.com/?p=6100I&b=16529 ↓ https://yoursite.com/?b=16529&q=results ↓ https://yoursite.com/?b=16529&q=q-dimensions ↓ https://yoursite.com/?b=16401&q=q-color-storm-door ↓ https://yoursite.com/?b=16385&q=q-material-storm-door ↓ https://yoursite.com/?b=1&q=q-door-type ↓ https://yoursite.com/ Each step backward: βœ“ Restores question state βœ“ Maintains bit value βœ“ Shows correct UI ``` --- ### Step 10: Refresh Page ``` At any point, user presses F5 to refresh Before Refresh: https://yoursite.com/?b=16529&q=q-dimensions After Refresh: https://yoursite.com/?b=16529&q=q-dimensions Result: βœ“ Returns to same question βœ“ Previous answers restored βœ“ Accumulated selections preserved βœ“ Can continue where they left off ``` --- ## 🎯 Bit Value Breakdown Reference ### Common Values You'll See | Bit Value | Decimal | What It Means | |-----------|---------|---------------| | `0000...0001` | 1 | Door selected | | `0000...0010` | 2 | Window selected | | `0001...0001` | 16385 | Door + Storm Door | | `0001...0011` | 16387 | Door + Window + Storm Door | | `0001...0011` | 16401 | Door + Aluminum + Storm Door | | `0010...0010` | 16529 | Door + Aluminum + White + Storm Door | ### Quick Decode Formula ``` To check if a bit is set: if (bitValue & (1 << bitPosition)) { // That attribute is selected } Examples: 16529 & 1 = 1 β†’ Door is selected βœ“ 16529 & 2 = 0 β†’ Window is NOT selected 16529 & 16 = 16 β†’ Aluminum is selected βœ“ 16529 & 128 = 128 β†’ White is selected βœ“ 16529 & 16384 = 16384 β†’ Storm Door is selected βœ“ ``` --- ## πŸ”— URL Patterns ### Navigation State ``` Pattern: /?b={bitValue}&q={questionKey} Example: /?b=16529&q=q-dimensions Use: Bookmark navigation progress ``` ### Product View ``` Pattern: /?p={productCode}&b={bitValue} Example: /?p=6100I&b=16529 Use: Direct link to product with context ``` ### Initial State ``` Pattern: / Example: https://yoursite.com/ Use: Fresh start, no parameters ``` --- ## πŸ’‘ Power User Features ### Hack the URL Users can manually modify URLs: ``` Original: /?b=16529&q=q-dimensions (Door + Aluminum + White + Storm Door) Modified: /?b=34&q=q-dimensions (Vinyl only) Result: Jumps directly to Vinyl products ``` ### Preset Configurations Your sales team can create bookmarks: ``` Residential Storm Doors: /?b=16401&q=results Commercial Windows: /?b=8194&q=results Budget Options (Vinyl): /?b=32&q=start ``` ### Analytics Tracking Track which combinations are popular: ``` Top URLs: /?b=16529 β†’ White Aluminum Storm Doors (2,453 views) /?b=8226 β†’ White Vinyl Windows (1,834 views) /?b=272 β†’ Bronze products (892 views) ``` --- ## πŸŽ“ Learning Example ### Try This Exercise: 1. Start at homepage (b=0) 2. Select Window (b=2) 3. Select Primary Window (b=8194) 4. Select Vinyl (b=8226) 5. Select White (b=8354) Your URL should be: `/?b=8354&q=q-dimensions` Decode: 8354 in binary = 10000010100010 - Bit 1 (2) = Window βœ“ - Bit 5 (32) = Vinyl βœ“ - Bit 7 (128) = White βœ“ - Bit 13 (8192) = Primary Window βœ“ Total: 2 + 32 + 128 + 8192 = 8354 βœ“ --- Ready to implement! πŸš€