Skip to content

Tag Archives: browser

Cookie Monster – WordPress URL Parameter Utility

I recently had a situation in which I needed to pass a URL parameter into WordPress so that it could be inserted into all links off of a blog page.  For example, a partner would pass traffic to a blog using the format http://www.myblog.com?refcode=joe.  All links embedded in the post would need to pass the value of refcode if it existed, even if the visitor requested multiple pages after the initial visit.

I created a Plugin (Cookie Monster) that will allow a Blog Admin to define which URL parameters should be captured, and then creates a shortcode so that the value can be used in your Posts and Pages.  A WordPress shortcode is a macro code that is embedded in your content.

In the example above, if you define refcode in the Cookie Monster Admin Settings, and if that URL parameter refcode contains a value in the querystring, it will automatically be saved into a cookie in the visitors browser. Anywhere that you place the shortcode in your Post, Cookie Monster will insert the querystring value into your Post.  The cookie value will persist across browser sessions.

If you click on this link, you will see that the querystring value refcode is now

Try changing refcode= in the link and reload this page.  Let me know if you have any further ideas for expanding this plugin.

You can download the latest copy here.

Web Analytics