{"id":281,"date":"2007-08-31T14:07:51","date_gmt":"2007-08-31T22:07:51","guid":{"rendered":"https:\/\/mikeindustries.com\/blog\/archive\/2007\/08\/adding-a-subscribe-bar-to-your-blog"},"modified":"2016-05-25T23:34:30","modified_gmt":"2016-05-26T06:34:30","slug":"adding-a-subscribe-bar-to-your-blog","status":"publish","type":"post","link":"https:\/\/mikeindustries.com\/blog\/archive\/2007\/08\/adding-a-subscribe-bar-to-your-blog","title":{"rendered":"Adding a &#8220;Subscribe&#8221; Bar to Your Blog"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp\/wp-content\/uploads\/subscribe_prompt.jpg\" width=\"450\" height=\"108\" alt=\"\" \/><\/p>\n<p>It makes me uneasy that such a huge number of people still visit blogs the old fashioned way: by checking them manually every now and then.  This, of course, is in opposition to subscribing via RSS and then only clicking over when there is new content.<\/p>\n<p>I am guilty of keeping an extremely unpredictable publishing schedule at Mike Industries, sometimes posting multiple times per week, and other times going almost a month without any new entries.  For this reason, I wish all readers were subscribers.  That way, no one would ever be greeting with old content.<\/p>\n<p>In an effort to convert more casual readers to subscribers, and hopefully convert people onto RSS in general, I&#8217;ve developed a PHP-powered module which prompts users to subscribe to my feed if they aren&#8217;t already.  Here&#8217;s how it works:<\/p>\n<ol>\n<li>If you come to Mike Industries and don&#8217;t have at least one of two cookies, you see a bar encouraging you to subscribe via RSS or e-mail.  One cookie is the &#8220;subscriber&#8221; cookie while the other one is the &#8220;promptclosed&#8221; cookie.<\/li>\n<li>If a user clicks over to Mike Industries from my feed, I set the &#8220;subscriber&#8221; cookie.  If a user manually clicks the &#8220;close this message&#8221; link in the module, I set the &#8220;promptclosed&#8221; cookie.  Both cookies last for three months.<\/li>\n<\/ol>\n<p>In order to accomplish this, you need to do a few things:<\/p>\n<ol>\n<li>Write some simple HTML to display your prompt message.  Include it at the top of every page of your blog, hopefully using something like PHP so you only have to do it once.  Using PHP, or your dynamic language of choice, set the message to only render if neither the &#8220;subscriber&#8221; nor the &#8220;promptclosed&#8221; cookies are set. Here&#8217;s what mine looks like:\n<p><textarea style=\"width: 400px; height: 100px\"><?php if (!isset($_COOKIE[\"subscriber\"]) &#038;&#038; !isset($_COOKIE[\"promptclosed\"])) {?><\/p>\n<div id=\"subscribe_prompt\"><a href=\"\/feed\" style=\"border-bottom: none; vertical-align: middle; position: relative;top: 2px; margin-right: 4px\"><img loading=\"lazy\" decoding=\"async\" src=\"\/blog\/images\/icon_feeds_black.gif\" alt=\"\" width=\"16\" height=\"16\" \/><\/a>Subscribe to Mike Industries via <a href=\"\/feed\">RSS<\/a> or <a href=\"javascript:void(0)\" onclick=\"document.getElementById('subscribe_emailform').style.display='block'\">e-mail<\/a> and be notified of new stuff automatically.<a href=\"javascript:void(0)\" class=\"subscribe_close\" onclick=\"setCookie('promptclosed', 'closed', now, '\/', HOST, '');document.getElementById('subscribe_prompt').style.display='none'\">Close this message<\/a><\/p>\n<div id=\"subscribe_emailform\">\n<form action=\"http:\/\/www.feedburner.com\/fb\/a\/emailverify\" method=\"post\" target=\"popupwindow\" onsubmit=\"window.open('http:\/\/www.feedburner.com', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true\">Enter your e-mail address: <input type=\"text\" style=\"width:150px; margin: 0 6px 0 6px; font-size: 10px\" name=\"email\" \/><input type=\"hidden\" value=\"http:\/\/feeds.feedburner.com\/~e?ffid=64422\" name=\"url\" \/><input type=\"hidden\" value=\"Mike Industries\" name=\"title\" \/> <input type=\"submit\" class=\"button-search\" value=\"Subscribe\" \/><\/form>\n<\/div>\n<\/div>\n<p><?php }?><\/textarea><\/li>\n<li>Modify the URLs in your feeds such that they pass a variable at the end like &#8220;how-to-make-a-margarita?subscribed=true&#8221;.<\/li>\n<li>Using PHP, or your dynamic language of choice, insert code right above the code in step 1 which checks for the presence of &#8220;subscribed=true&#8221; in the query string and sets the &#8220;subscribed&#8221; cookie accordingly.<\/li>\n<\/ol>\n<p><em>* Note: If you are using <a href=\"http:\/\/www.haveamint.com\">Mint w\/ BirdFeeder<\/a> like I am, you can skip steps 2 and 3 and just add the following to Birdfeeder&#8217;s <code>class.php<\/code> right above the line that says<\/em> <code>header(\"Location:{$_GET['seed']}\");<\/code>:<\/p>\n<p><textarea style=\"width: 450px; height: 50px\">$subscriber_expire = gmstrftime(&#8220;%A, %d-%b-%Y %H:%M:%S&#8221;, (mktime()+(60*60*24*90)));header(&#8220;Set-Cookie: subscriber=true; expires=$subscriber_expire; path=\/; domain=yourdomain.com&#8221;);<\/textarea><\/p>\n<p>Voila.  That&#8217;s it.  An unobtrusive message encouraging you to subscribe which goes away after you either subscribe or decide to close the message.<\/p>\n<p>Interestingly, I got this idea while <a href=\"https:\/\/mikeindustries.com\/blog\/archive\/2006\/11\/results-from-the-google-adsense-experiment\">experimenting with Google AdSense several months ago<\/a>.  I only wanted to show the ads to casual passers-by (perhaps coming in through search engines) and not to Mike Industries subscribers.  Now that we have the ability to set cookies and identify who is a subscriber, we can do all sorts of things.  I can imagine a small subset of features on the site which are perhaps only made available to subscribers.  Who knows.  I like the possibilities though.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It makes me uneasy that such a huge number of people still visit blogs the old fashioned way: by checking them manually every now and then.  This, of course, is in opposition to subscribing via RSS and then only clicking over when there is new content.<\/p>\n<p>I am guilty of keeping an extremely unpredictable publishing schedule at Mike Industries, sometimes posting multiple times per week, and other times going almost a month without any new entries.  For this reason, I wish all readers were subscribers.  That way, no one would ever be greeting with old content.<\/p>\n<p>In an effort to convert more casual readers to subscribers, and hopefully convert people onto RSS in general, I&#8217;ve developed a PHP-powered module which prompts users to subscribe to my feed if they aren&#8217;t already.  Here&#8217;s how it works:&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,282],"tags":[],"class_list":["post-281","post","type-post","status-publish","format-standard","hentry","category-code","category-original"],"_links":{"self":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts\/281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/comments?post=281"}],"version-history":[{"count":0,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts\/281\/revisions"}],"wp:attachment":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/media?parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/categories?post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/tags?post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}