Skip to content

Instantly share code, notes, and snippets.

@cdlewis
Created March 14, 2015 17:52
Show Gist options
  • Save cdlewis/758d00224e4f3f3afd56 to your computer and use it in GitHub Desktop.
Save cdlewis/758d00224e4f3f3afd56 to your computer and use it in GitHub Desktop.
// Social Sharing URL
function social_sharing_url() {
var base_url = document.URL.replace( /\?.*?$/, '' );
query_params = []
if( window.title_variation ) {
query_params.push( [ 'title_var', window.title_variation ] );
}
if( window.optimizely_query_key ) {
query_params.push( [ window.optimizely_query_key, window.optimizely_query_value ] );
}
jQuery( query_params ).each( function( index, value ) {
var operator = ( index == 0 ) ? '?' : '&';
base_url += "{0}{1}={2}".format( operator, escape( value[ 0 ] ), escape( value[ 1 ] ) );
} );
return base_url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment