function parseReferrer(url) {
    // Extract current URL parameters
    const currentUrl = new URL(url || window.location.href);
    
    // Parse source parameters
    const refParam = currentUrl.searchParams.get('ref');
    const sourceParam = currentUrl.searchParams.get('source');
    const utmSourceParam = currentUrl.searchParams.get('utm_source');
    const utmMediumParam = currentUrl.searchParams.get('utm_medium');
    
    // Determine primary source
    const referrerSource = refParam || sourceParam || utmSourceParam || null;
    
    // Check portal hash if needed
    if (!referrerSource && currentUrl.hash && currentUrl.hash.includes('#/portal')) {
        return parsePortalHash(currentUrl);
    }
    
    return {
        source: referrerSource,
        medium: utmMediumParam || null,
        url: window.document.referrer || null
    };
}
Parses URL parameters to extract attribution information

@param {string} url - The URL to parse
@returns {Object} Parsed attribution data