This implementation adds viral growth features to Music Blocks to increase word-of-mouth spread and user engagement. The solution addresses issue #5944 by implementing multiple viral loop mechanisms.
Users can now share their Music Blocks projects directly to social media platforms:
- Twitter/X: Share with custom text and hashtags (#MusicBlocks, #Coding, #Music)
- Facebook: Direct sharing to Facebook timeline
- WhatsApp: Share via WhatsApp with project link
- Email: Share via email with pre-filled subject and body
- Copy Link: Copy shareable link to clipboard
- Each user gets a unique referral code (format: MB + 6 random characters)
- Referral codes are automatically appended to shared URLs
- System tracks when new users arrive via referral links
- Referral data stored in localStorage for analytics
Gamification to encourage sharing:
- First Share: Awarded when user shares their first project
- Social Butterfly: Awarded after sharing 5 projects
- Influencer: Awarded after sharing 10 projects
Achievements are displayed with animated notifications and tracked in user profile.
- Modern modal interface for sharing options
- Visual project preview in share modal
- Platform-specific share buttons with icons
- Referral code display
- Share statistics tracking
- Added "Share on social media" button to global project cards
- Viral share modal accessible from project actions
- Added "Share on social media" button to local project cards
- Works for both published and unpublished projects
- Encourages users to publish before sharing
-
js/ViralLoops.js - Core viral loops functionality
- ViralLoops class managing all viral features
- Social sharing methods for each platform
- Referral tracking system
- Achievement management
- Modal UI generation
-
css/viral-loops.css - Styling for viral features
- Share modal styling
- Achievement notification animations
- Responsive design
- Dark mode support
-
VIRAL_LOOPS_IMPLEMENTATION.md - This documentation
-
index.html
- Added viral-loops.css stylesheet
- Added ViralLoops.js script
-
js/activity.js
- Initialize ViralLoops instance on activity startup
- Make viralLoops available globally via window.viralLoops
-
planet/js/GlobalCard.js
- Added viral share button to project cards
- Added event listener for viral share modal
-
planet/js/LocalCard.js
- Added viral share button to local project cards
- Added event listener for viral share modal
-
Sharing a Project:
- Open Planet interface (Find and share projects button)
- Navigate to Local or Global tab
- Click the "Share on social media" icon (iOS share icon)
- Choose your preferred sharing platform
- Share and earn achievements!
-
Viewing Achievements:
- Achievements appear as animated notifications
- Track progress in share modal (shows share count)
-
Referral System:
- Your unique referral code is displayed in share modal
- All shared links automatically include your referral code
- When friends click your link, you get credit
// Access viral loops instance
const viralLoops = window.viralLoops;
// Show share modal programmatically
viralLoops.showShareModal('My Project Title', 'project-id-123', 'image-url');
// Track custom share
viralLoops.trackShare('custom-platform');
// Generate share URL with referral
const shareURL = viralLoops.generateShareURL('project-id', { run: true });
// Show achievements
viralLoops.showAchievements();Users create → Users share → New users discover → New users create
Share project → Earn achievement → Feel accomplished → Share more
Share with referral → Friends join → Friends create → Friends share
See shared projects → Get inspired → Create own → Share to show off
The system tracks:
- Total share count per user
- Platform-specific share counts
- Referral arrivals
- Achievement unlocks
- All data stored in localStorage
Potential additions for even stronger viral loops:
- Leaderboards: Show top sharers and creators
- Referral Rewards: Unlock special features for successful referrals
- Social Feed: Display recently shared projects on homepage
- Collaboration Features: Allow multiple users to work on projects
- Remix Tracking: Track when projects are remixed and shared
- Email Notifications: Notify users when their projects are shared
- Social Media Embeds: Allow embedding Music Blocks projects in social posts
- Trending Section: Highlight most-shared projects
- Share Challenges: Time-limited challenges to encourage sharing
- Integration with Music Blocks Community: Connect with forums/Discord
- No personal data is collected
- Referral codes are anonymous
- All tracking is local (localStorage)
- No external analytics services
- Users control what they share
- Modern browsers with ES6 support
- localStorage support required
- Clipboard API for copy functionality
- Works on mobile and desktop
To test the implementation:
- Open Music Blocks
- Create or open a project
- Click "Find and share projects"
- Click the iOS share icon on any project card
- Try different sharing options
- Check for achievement notifications
- Verify referral code in share modal
- Test share links with referral codes
- Minimal: ~15KB additional JavaScript
- ~5KB additional CSS
- No external dependencies
- Lazy-loaded modals
- Efficient localStorage usage
- Keyboard navigation support
- Screen reader friendly
- High contrast mode compatible
- Touch-friendly buttons
- Clear visual feedback
Same as Music Blocks: GNU Affero General Public License v3.0
Implemented for issue #5944: "Add viral loops across musicblocks to increase word of mouth spread"
- Enable viral loops: Already enabled by default
- Share your first project: Click share icon → Choose platform → Share!
- Earn achievements: Keep sharing to unlock all badges
- Track your impact: View share count in share modal
- Spread the word: Your referral code helps grow the community!
For issues or questions about viral loops:
- Open an issue on GitHub
- Tag with "viral-loops" label
- Reference issue #5944