You don't want to track and update a counter on every page hit, it'll have performance problems, won't work on cached pages, and the data will be prone to race conditions
@Rarst that filter_var on top may produce some unwanted result... E.g. any URL that contains unencoded & in the path or in the query string will be just returned as is, which I think is not ok for your purpose...