<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Constant.co.za</title>
	<atom:link href="http://constant.co.za/feed/" rel="self" type="application/rss+xml" />
	<link>http://constant.co.za</link>
	<description>Thoughts of a developer and entrepreneur</description>
	<lastBuildDate>Sat, 18 Feb 2012 20:08:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Superfish Menu Fadeout</title>
		<link>http://constant.co.za/2012/02/superfish-menu-fadeout/</link>
		<comments>http://constant.co.za/2012/02/superfish-menu-fadeout/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 20:08:39 +0000</pubDate>
		<dc:creator>Constant M</dc:creator>
				<category><![CDATA[Superfish]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://constant.co.za/?p=86</guid>
		<description><![CDATA[I use the Thematic framework for all the WordPress themes I develop. It ships with Superfish by default to handle the menus. Only issue with Superfish is that it doesn&#8217;t fade out menus, which looks a bit wonky. I&#8217;ve done &#8230; <a href="http://constant.co.za/2012/02/superfish-menu-fadeout/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I use the Thematic framework for all the WordPress themes I develop. It ships with Superfish by default to handle the menus. Only issue with Superfish is that it doesn&#8217;t fade out menus, which looks a bit wonky. I&#8217;ve done a search or two and couldn&#8217;t find anything on Google that was newer that 2008 or didn&#8217;t 404. I made a quick hack to the hideSuperfishUl function in superfish.js to fade out the submenus. This hasn&#8217;t been tested on submenus of submenus, but seems to work fine on single tier menus.</p>
<pre>        hideSuperfishUl: function() {
            var e = a.op,
            d = (e.retainPath === true) ? e.$path: "";
            e.retainPath = false;
            var c = b(["li.", e.hoverClass].join(""), this).add(this).not(d).find("&gt;ul").fadeOut('fast',function(){
				jQuery(this).removeClass(e.hoverClass)
			});
            e.onHide.call(c);
            return this
        },</pre>
<p>Just replace that part of the file, and it should work.</p>
]]></content:encoded>
			<wfw:commentRss>http://constant.co.za/2012/02/superfish-menu-fadeout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easily port an existing database to Rails</title>
		<link>http://constant.co.za/2011/08/easily-port-an-existing-database-to-rails/</link>
		<comments>http://constant.co.za/2011/08/easily-port-an-existing-database-to-rails/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 15:13:10 +0000</pubDate>
		<dc:creator>Constant M</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://constant.co.za/?p=73</guid>
		<description><![CDATA[I&#8217;m busy porting Moo Invoicing from CodeIgniter to Ruby on Rails, and I&#8217;ve come to the point where I need to somehow get the existing MySQL database into the new PostGres database, along with the differing schema. Initially I thought &#8230; <a href="http://constant.co.za/2011/08/easily-port-an-existing-database-to-rails/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m busy porting Moo Invoicing from CodeIgniter to Ruby on Rails, and I&#8217;ve come to the point where I need to somehow get the existing MySQL database into the new PostGres database, along with the differing schema. Initially I thought the best way would be to connect to the existing MySQL database from Rails, but I couldn&#8217;t find enough information on how to do this. I then settled for an easier way &#8211; Convert the MySQL database dump to YAML, load it up in a Rails controller and do everything from there. As of writing, I&#8217;ve not yet done what I&#8217;m planning to do, but it should go something like this:</p>
<p>1 &#8211; Dump the database and convert it to YAML using <strong><a title="MySQL to YAML" href="http://www.franzone.com/2010/07/16/dump-a-mysql-database-to-yaml-using-php/" target="_blank">this</a></strong> PHP library by Jonathan Franzone.</p>
<p>2 &#8211; In your Rails controller, open the YAML file:</p>
<pre>oldDatabase = YAML.load(File.open("pathtofile.yml"))</pre>
<p>3 &#8211; And bam, you have an object of your whole database that you can iterate through and create new rows from through Active Record!</p>
<pre>oldDatabase.clients.each do |client|
    Client.create(:name =&gt; client.name)
end</pre>
<p>Now, to apply my theory and hope it works. <img src='http://constant.co.za/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://constant.co.za/2011/08/easily-port-an-existing-database-to-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails :resources routed to different controller</title>
		<link>http://constant.co.za/2011/07/rails-resources-route-to-different-controller/</link>
		<comments>http://constant.co.za/2011/07/rails-resources-route-to-different-controller/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 11:51:00 +0000</pubDate>
		<dc:creator>Constant M</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[resources]]></category>
		<category><![CDATA[routing]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://constant.co.za/?p=58</guid>
		<description><![CDATA[A bit of background info: I&#8217;m busy porting Moo Invoicing to Rails as it&#8217;s just become too cumbersome to add features to and update in it&#8217;s current state. It&#8217;s written in CodeIgniter, but the time you save writing something in &#8230; <a href="http://constant.co.za/2011/07/rails-resources-route-to-different-controller/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A bit of background info: I&#8217;m busy porting Moo Invoicing to Rails as it&#8217;s just become too cumbersome to add features to and update in it&#8217;s current state. It&#8217;s written in CodeIgniter, but the time you save writing something in Rails as compared to your average PHP framework is more than noticeable.</p>
<p>Now, in Moo Invoicing you have invoices and quotes. They&#8217;re effectively the same thing, but with some minor differences (due date, payments, etc.) So, instead of having a heap of duplicate code, it makes sense to use the same controllers, models and views for both quotes and invoices. I did pretty much the same thing in CodeIgniter, but rails does much more magic in the background, so to hack it to do your bidding is usually a bad idea and can cause you to loose quite a few &#8220;features&#8221; the framework provides. Also, being new with Rails, you frequently come to times where you think that what you&#8217;re trying to do will be &#8220;too advanced&#8221; for the framework to handle, and you&#8217;ll need to do some actual coding, and more frequently you realize that you&#8217;re wrong. Most of the time, the Rails guys have a SUPER easy way out. This is one of those cases &#8211; it just wasn&#8217;t in any of the Rails guides.<span id="more-58"></span> So, for my Invoices, I have the following routes:</p>
<pre>➜  bundle exec rake routes | grep invoice
                invoices GET    /invoices(.:format)                         {:controller=&gt;"invoices", :action=&gt;"index"}
                         POST   /invoices(.:format)                         {:controller=&gt;"invoices", :action=&gt;"create"}
             new_invoice GET    /invoices/new(.:format)                     {:controller=&gt;"invoices", :action=&gt;"new"}
            edit_invoice GET    /invoices/:id/edit(.:format)                {:controller=&gt;"invoices", :action=&gt;"edit"}
                 invoice GET    /invoices/:id(.:format)                     {:controller=&gt;"invoices", :action=&gt;"show"}
                         PUT    /invoices/:id(.:format)                     {:controller=&gt;"invoices", :action=&gt;"update"}
                         DELETE /invoices/:id(.:format)                     {:controller=&gt;"invoices", :action=&gt;"destroy"}</pre>
<p>So, all the routes generated by having the following in your routes.rb file:</p>
<pre>resources :invoices</pre>
<p>Now, how would I get it so it instead of invoices, it says quotes? ie:</p>
<pre>➜  bundle exec rake routes | grep quotes
                  quotes GET    /quotes(.:format)                           {:controller=&gt;"invoices", :action=&gt;"index"}
                         POST   /quotes(.:format)                           {:controller=&gt;"invoices", :action=&gt;"create"}
               new_quote GET    /quotes/new(.:format)                       {:controller=&gt;"invoices", :action=&gt;"new"}
              edit_quote GET    /quotes/:id/edit(.:format)                  {:controller=&gt;"invoices", :action=&gt;"edit"}
                   quote GET    /quotes/:id(.:format)                       {:controller=&gt;"invoices", :action=&gt;"show"}
                         PUT    /quotes/:id(.:format)                       {:controller=&gt;"invoices", :action=&gt;"update"}
                         DELETE /quotes/:id(.:format)                       {:controller=&gt;"invoices", :action=&gt;"destroy"}</pre>
<p>Very easily, apparently. Just specify the controller that resources should point to. In your routes.db file:</p>
<pre>resources :quotes, :controller=&gt;'invoices'</pre>
<p>Yup, Rails is amazing.</p>
]]></content:encoded>
			<wfw:commentRss>http://constant.co.za/2011/07/rails-resources-route-to-different-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting ImageMagick to work with Lion and ZSH</title>
		<link>http://constant.co.za/2011/07/getting-imagemagick-to-work-with-lion-and-zsh/</link>
		<comments>http://constant.co.za/2011/07/getting-imagemagick-to-work-with-lion-and-zsh/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 21:11:55 +0000</pubDate>
		<dc:creator>Constant M</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[Lion]]></category>
		<category><![CDATA[OhMyZSH]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[ZSH]]></category>

		<guid isPermaLink="false">http://constant.co.za/?p=44</guid>
		<description><![CDATA[Don&#8217;t really know if this issue is specific to Lion and ZSH, but upon extracting the ImageMagick binary package (from here) to /usr/local/ on Lion, I couldn&#8217;t get it to work as per the instructions on the ImageMagick site. I &#8230; <a href="http://constant.co.za/2011/07/getting-imagemagick-to-work-with-lion-and-zsh/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t really know if this issue is specific to Lion and ZSH, but upon extracting the ImageMagick binary package (from <a href="http://www.imagemagick.org/script/binary-releases.php#macosx">here</a>) to /usr/local/ on Lion, I couldn&#8217;t get it to work as per the instructions on the ImageMagick site. I would just download it or use the Rails gem (rmagick), but since I installed Lion, make doesn&#8217;t work any longer and since it&#8217;s nearing the end of the month I can&#8217;t stand off the bandwidth for the xcode4 download.<span id="more-44"></span>So, this:</p>
<pre>➜  ~  identify</pre>
<p>Gave the following output:</p>
<pre>dyld: Library not loaded: /ImageMagick-6.7.1/lib/libMagickCore.4.dylib
  Referenced from: /usr/local/ImageMagick-6.7.1/bin/identify
  Reason: image not found</pre>
<p>In case you were wondering, the &#8220;image not found&#8221; it refers to is the library mentioned on the first line, not the image your trying to manipulate with ImageMagick. I actually part of the solution to the problem on StackOverflow <a href="http://stackoverflow.com/questions/4953235/imagemagick-convert-exit-status-133">here</a>. It that ZSH, and subsequently Rails, has the wrong path to the libMagickCore.4.dylib library &#8211; the path in the error <em>does </em>look a bit funky.</p>
<p>So, solution was to add the following to my .zshrc (if case you don&#8217;t know, it&#8217;s in your home directory)</p>
<pre>export DYLD_LIBRARY_PATH=/usr/local/ImageMagick-6.7.1/lib</pre>
<p>PS. Don&#8217;t forget to also add the MAGICK_HOME path, as well as add the the bin path to your PATH. Your paths in .zshrc should look something like the following:</p>
<pre># Customize to your needs...
export MAGICK_HOME=/usr/local/ImageMagick-6.7.1/
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin/:/usr/local/ImageMagick-6.7.1/bin
export DYLD_LIBRARY_PATH=/usr/local/ImageMagick-6.7.1/lib</pre>
<p>Hope this prevents some hair loss for somebody <img src='http://constant.co.za/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://constant.co.za/2011/07/getting-imagemagick-to-work-with-lion-and-zsh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mercurial and Git both broken!</title>
		<link>http://constant.co.za/2011/07/mercurial-and-git-both-broken/</link>
		<comments>http://constant.co.za/2011/07/mercurial-and-git-both-broken/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 20:28:52 +0000</pubDate>
		<dc:creator>Constant M</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[10.7]]></category>
		<category><![CDATA[Broken]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Lion]]></category>
		<category><![CDATA[Mercurial]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Versioning]]></category>

		<guid isPermaLink="false">http://constant.co.za/?p=38</guid>
		<description><![CDATA[So, after I installed Lion last night, it seems both my Mercurial and Git installations broke. Somehow, Git&#8217;s path disappeared from my .zshrc: ➜  locomotive  git zsh: correct 'git' to '_git' [nyae]? Fixed it by just adding :/usr/local/git/bin/  back to the &#8230; <a href="http://constant.co.za/2011/07/mercurial-and-git-both-broken/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, after I installed Lion last night, it seems both my Mercurial and Git installations broke. Somehow, Git&#8217;s path disappeared from my .zshrc:</p>
<pre>➜  locomotive  git
zsh: correct 'git' to '_git' [nyae]?</pre>
<p><span id="more-38"></span>Fixed it by just adding :/usr/local/git/bin/  back to the export path at the bottom of the file:</p>
<pre># Customize to your needs...
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin/</pre>
<div>I can&#8217;t see how this possibly had anything to do with the Lion upgrade, but now you have one more thing to try if your Git breaks.</div>
<div>Then, Mercurial also broke:</div>
<div>
<pre>abort: couldn't find mercurial libraries in [/usr/platlib/Library/Python/2.6/site-packages /usr/local/bin /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7 /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC /Library/Python/2.7/site-packages]
(check your install and PYTHONPATH)</pre>
<div>It seems you need a new version of Mercurial for Lion, which can be downloaded <a title="Mercurial Download" href="http://mercurial.berkwood.com/binaries/Mercurial-1.9-py2.7-macosx10.7.zip" target="_blank">here</a>. Install it over your current installation and all works again. Tada!</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://constant.co.za/2011/07/mercurial-and-git-both-broken/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My comfort zone</title>
		<link>http://constant.co.za/2010/09/my-comfort-zone/</link>
		<comments>http://constant.co.za/2010/09/my-comfort-zone/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 12:12:57 +0000</pubDate>
		<dc:creator>Constant M</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[comfort zones]]></category>
		<category><![CDATA[moo invoicing]]></category>
		<category><![CDATA[personal development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://constant.co.za/?p=32</guid>
		<description><![CDATA[I today realized that I&#8217;ve slipped into a comfort zone &#8211; this is bad thing. Comfort zones hinder learning and personal development. Falling into a comfort zone can kill you and turn you into a hypothetical zombie. I&#8217;ve moved into &#8230; <a href="http://constant.co.za/2010/09/my-comfort-zone/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I today realized that I&#8217;ve slipped into a comfort zone &#8211; this is bad thing. Comfort zones hinder learning and personal development. Falling into a comfort zone can kill you and turn you into a hypothetical zombie. I&#8217;ve moved into a house and got myself a Land Rover and I&#8217;m living a comfortable lifestyle – I generally have everything I want and have wanted for the past couple of years. What now? Now I&#8217;m bored.<span id="more-32"></span>The upcoming launch of <a title="Moo Invoicing" href="http://mooinvoicing.com" target="_blank">Moo Invoicing</a> should provide come excitement in the form of seeing something I created grow and expand, but only on a temporary scale. It&#8217;s been far too long since I&#8217;ve seen new places and done new things. In the form of new things, I&#8217;m busy learning Ruby on Rails (yes, I&#8217;m an extremely late adopter of RoR). The technology and thinking behind the Rails community is something that has not been seen in the PHP community for, well, possibly ever. I mean, look at Smarty, and then look at HAML. And LessCSS. And Sinatra. And Rails. ZOMG. And, on the flip side, all things awesome in PHP is based on something the Ruby community came up with. Look at Code Igniter and CakePHP. I&#8217;m not entirely dismissing PHP – I just think Ruby is a much amazing language to work in, mostly due to the community behind it. Also, look at the creators of PHP and Ruby:</p>
<p><strong> Ruby:</strong></p>
<p><img class="size-full wp-image-33 alignleft" title="220px-Yukihiro_Matsumoto" src="http://constant.co.za/wp-content/uploads/2010/09/220px-Yukihiro_Matsumoto.jpg" alt="" width="220" height="328" /></p>
<p><strong>PHP:</strong></p>
<p><a href="http://constant.co.za/wp-content/uploads/2010/09/250px-Wikirl.jpg"><img class="size-full wp-image-34 alignnone" title="250px-Wikirl" src="http://constant.co.za/wp-content/uploads/2010/09/250px-Wikirl.jpg" alt="" width="250" height="238" /></a></p>
<p>Nuff said. <img src='http://constant.co.za/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>As I was saying new places and new things – by new places I&#8217;ll probably look into heading to the US in the next year or so. Althought there&#8217;s an insane amount of opportunities here, I&#8217;m a bit bored of South Africa and what it has to offer at the moment. I&#8217;m hungry to get more external experiences and influences.</p>
<p>And that, ladies and gentleman, was my first personal rant on my blog. I hope to now start a PHP vs Ruby flame war here as to generate lots of traffic.</p>
]]></content:encoded>
			<wfw:commentRss>http://constant.co.za/2010/09/my-comfort-zone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook conversion tracking with Contact Form 7</title>
		<link>http://constant.co.za/2010/07/facebook-conversion-tracking-with-contact-form-7/</link>
		<comments>http://constant.co.za/2010/07/facebook-conversion-tracking-with-contact-form-7/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 15:01:08 +0000</pubDate>
		<dc:creator>Constant M</dc:creator>
				<category><![CDATA[Social Media]]></category>
		<category><![CDATA[advertising]]></category>
		<category><![CDATA[contact form 7]]></category>
		<category><![CDATA[conversion tracking]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[follow through]]></category>
		<category><![CDATA[tracking]]></category>
		<category><![CDATA[tracking code]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://constant.co.za/?p=5</guid>
		<description><![CDATA[I was recently asked to add Facebook ad tracking code to one of my WordPress sites which uses the excellent Contact Form 7 plug-in. Doing a quick Google search to find out if there was a best-practice way of doing &#8230; <a href="http://constant.co.za/2010/07/facebook-conversion-tracking-with-contact-form-7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was recently asked to add Facebook ad tracking code to one of my WordPress sites which uses the excellent <a title="Contact Form 7" href="http://wordpress.org/extend/plugins/contact-form-7/" target="_blank">Contact Form 7</a> plug-in. Doing a quick Google search to find out if there was a best-practice way of doing this, I didn&#8217;t come up with anything. Thus, if you&#8217;re wondering how to track your facebook ads on your WordPress site using Contact Form 7, this quick tutorial should help you out!<span id="more-5"></span>The Facebook tracking code provided by Facebook to put on your contact &#8216;Thank You&#8217; page should look something like the following:</p>
<pre>&lt;script src="//ah8.facebook.com/js/conversions/tracking.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
 FB.Insights.impression({
 'id' : 3546876354,
 'h' : '3bc5e0f'
 });
} catch (e) {}
&lt;/script&gt;</pre>
<h3>STEP 1 &#8211; Open the theme footer file</h3>
<p>Firstly, we need to edit your theme&#8217;s footer file, and add in the Facebook tracking Javascript file. The easiest way to do this is to go to Appearance-&gt;Editor in your WordPress admin.</p>
<p><img class="alignnone size-full wp-image-8" title="Wordpress Theme Editor" src="http://constant.co.za/wp-content/uploads/2010/07/editor.jpg" alt="Wordpress Theme Editor" width="179" height="199" /></p>
<p>Once you have the theme editor open, look for footer.php on the right sidebar. It&#8217;s a good idea just to copy and paste the content of this file and save it on your desktop in case something goes wrong.</p>
<p><img class="alignnone size-full wp-image-9" title="Wordpress Footer" src="http://constant.co.za/wp-content/uploads/2010/07/footer.jpg" alt="Wordpress Footer" width="257" height="106" /></p>
<h3>STEP 2 &#8211; Edit the theme footer code</h3>
<p>When footer.php has been loaded up, look for the following piece of code:</p>
<pre>&lt;?php wp_footer() ?&gt;</pre>
<p>And change it to:</p>
<pre>&lt;script src="//ah8.facebook.com/js/conversions/tracking.js"&gt;&lt;/script&gt;
&lt;?php wp_footer() ?&gt;</pre>
<p>This will load up the Facebook tracking Javascript functions, so that we can excute them later from Contact Form 7. The reason I put this in the footer is:</p>
<ol>
<li>Because it&#8217;s not priority like the rest of your blog, it&#8217;ll only load last. This is also in accordance with the <a title="http://developer.yahoo.com/performance/rules.html" href="http://developer.yahoo.com/performance/rules.html" target="_blank">Yahoo Best Practices</a>.</li>
<li>Because the footer.php is almost always less cluttered with code than the header, it&#8217;ll make it easier for less experienced users to insert the code.</li>
</ol>
<p>After changing the code, click on &#8216;Update File&#8217;. This will save the footer file.<em></em></p>
<h3>STEP 3 : Add tracking code to Contact Form 7</h3>
<p>Right, now that we have the relevant Javascript file in place, we can get Contact Form 7 to execute the tracking code when a user submits the contact form. To do this, we&#8217;ll go the settings page of Contact Form 7. This can be found on the left sidebar of the WordPress admin.</p>
<p><em><img class="alignnone size-full wp-image-10" title="Contact Form 7 Settings" src="http://constant.co.za/wp-content/uploads/2010/07/contactformsettings.jpg" alt="Contact Form 7 Settings" width="172" height="67" /></em></p>
<p>When in the settings page, scroll down to &#8220;Additional Settings&#8221; and click &#8216;show&#8217;.</p>
<p><img class="alignnone size-full wp-image-11" title="Contact Form 7 Additional Settings" src="http://constant.co.za/wp-content/uploads/2010/07/adddisettings.jpg" alt="Contact Form 7 Additional Settings" width="281" height="88" /></p>
<p>You now have to reference the code provided by facebook and get the &#8216;<span style="color: #ff0000;">id</span>&#8216; and &#8216;<span style="color: #339966;">h</span>&#8216; values:</p>
<pre>try {
 FB.Insights.impression({
 'id' : <span style="color: #ff0000;">3546876354</span>,
 'h' : '<span style="color: #339966;">3bc5e0f</span>'
 });
} catch (e) {}</pre>
<p>Take these values and put them in the following code:</p>
<pre>on_sent_ok: "FB.Insights.impression({'id' : <span style="color: #ff0000;"><span style="color: #000000;">'</span>id here<span style="color: #000000;">'</span></span>, 'h' : '<span style="color: #339966;">h here</span>'});"</pre>
<p>So it resembles like the following:</p>
<pre>on_sent_ok: "FB.Insights.impression({'id' : '3546876354', 'h' : '3bc5e0f'});"</pre>
<p>You can then take this piece of code and insert into the Additional Settings area you opened. It will then look something like the following:</p>
<p><img class="alignnone size-medium wp-image-12" title="Additional Settings with Code" src="http://constant.co.za/wp-content/uploads/2010/07/done-300x64.jpg" alt="Additional Settings with Code" width="300" height="64" /></p>
<p>You can now click &#8216;Save&#8217; to apply your changes. You should add the code to each of your contact forms, if you have created more than one. And that&#8217;s it, your Facebook ad conversion tracking should now work!</p>
<p><strong>NOTE:</strong> If you use any caching plug-ins, you should probably empty the cache to take the changes you made into effect.</p>
<p>Edit:</p>
<p>There are quite a few posts around that goes through this step by step, but you can use the Google Analytics Asynchronous library (not the standard one) and track conversions like this:</p>
<pre>on_sent_ok:"_gaq.push(['_trackPageview', '/about/contact/shop-thanks']);"

To combine the two, you could seperate the two trackers with a semicolon:</pre>
<pre> on_sent_ok:"_gaq.push(['_trackPageview', '/about/contact/shop-thanks']);FB.Insights.impression({'id' : '3546876354', 'h' : '3bc5e0f'});"</pre>
]]></content:encoded>
			<wfw:commentRss>http://constant.co.za/2010/07/facebook-conversion-tracking-with-contact-form-7/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: constant.co.za @ 2012-02-22 23:21:10 -->
