Pass custom query strings across website I want to use some custom query strings for tracking purposes and for visibility rules. The goal is, to provide a link such as www.example.com#affiliateid=1 and the string is preserved through the whole web session. Ideally, # should be used instead of ?, as it is ignored by google and prevents duplicate content. 

However, each time I click a link on my site, the parameters are lost. 

I don't really know where to start -
are they usually passed and is this a problem with url rewrite or would I have to learn drupal that it should append the strings to each link?

Thank you!
That's probably a bit messy. Have you considered using cookies or even the session variable?

Edit:
Turns out it might actually be possible and without much fuss! Thanks OP for raising the question and making us question (and research) this a bit. 

Drupal has a hook to rewrite all URLs (hook_url_outbound_alter), which coming to think about it makes total sense. 

Basically you can use this hook to grab a session variable or a cookie - you still want to store it somewhere just so that in case you lose it at some point you can easily retrieve it and recover the navigation - and rewrite the URLs according to whatever rules you need. 

Here's a sample for future reference, not mine just adding it here so we don't lose it if the link breaks:

&lt;?php
/* Helper function for using strpos with an array of strings.
 */

function strposa ($haystack, $needles) {
    $bool = false;
    foreach ($needles as $needle) {
        if (strpos($haystack, $needle) !== false) {
            $bool = true;
        }
    }
    return $bool;
}

/* Implements hook_url_outbound_alter
 */

function rl_int_url_url_outbound_alter(&amp;$path, &amp;$options, $original_path) { 
    //Break path into an array
    $arr = explode('/',$path);
    //Get country list and exclude paths
    $c_list = array('us','ca');
    $system_paths = array('admin', 'user', 'sites', 'system');
    $exclude_paths = array('node/add', 'sitemap');
    //If the path contains a system path in the first argument, or has an exclude path in the full path string, do not set a prefix.
    if (in_array($arr[0], $system_paths) || strposa($path, $exclude_paths)) {
        $options['prefix'] = '' ;
    //OK, it's not an excluded path. If the path doesn't have the prefix already, add a prefix.
    } else if (in_array($arr[0], $c_list) == false) {
        $c = $_COOKIE('Drupal_visitor_country');
        $l = $_COOKIE('Drupal_visitor_language');
        $options['prefix'] = $c . '/' . $l . '/';
        //Special case: remove "home" from the path if it's the home page, so that it's example.com/us/en instead of example.com/us/en/home.
        if (drupal_lookup_path('alias', $path) === 'home') {
            $path = '';
        }
    }
}
?&gt;


Hope this helps!