<script type="text/javascript">
$(document).ready(function () {
    var queryStringValue = GetUrlKeyValue('MyPropertyName', window.location.href);
    if(!queryStringValue){
        queryStringValue="0";
    }
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', writeProperty("MyPropertyName",queryStringValue));    

});    

function writeProperty(propertyName, propertyValue) {
    var clientContext;
    clientContext = SP.ClientContext.get_current();
    var web = clientContext.get_site().get_rootWeb();
    this.props = web.get_allProperties();
    this.props.set_item(propertyName, propertyValue);  
    web.update();
    clientContext.executeQueryAsync(Function.createDelegate(this, writePropertySuccess), Function.createDelegate(this, writePropertyFailed));
}
function writePropertySuccess(){
    var nid = SP.UI.Notify.addNotification("Property registered", false);  
}
function writePropertyFailed(sender, args){
    var nid = SP.UI.Notify.addNotification("Failure while trying to write the property: " + args.get_message(), false);
}
</script>