Archive for July 2009

 
 

PPC campaign for Bed and Breakfast

The name or URL strictlyPHP may not immediately reveal I have a second online passion: Web Analytics.

I am more than aware a proper site would help clarify what I do and it’s certainly on the list, but for now, a short description: besides PHP/Web development, I try to invest as much time as possible in Web Analytics. In my case summarized as: website optimization using Google Analytics.

I am extremely fascinated by the information you can derive from analysing data/traffic. I like to pin-point possible usability issues, missing information or missed opportunities to improve site conversion performance. Related to that, targeted AdWords PPC (Pay-Per-Click) campaigns are lots of fun too!

De Pastorie in Haspengouw

And that is what made me write this post: I just started a new Google PPC campaign for a small Bed and Breakfast in Haspengouw (Belgium) targeted to Belgian and Dutch people.

The conversion action is of course the use of the contact form and as results are coming in, it’s doing well. I did a small site rebuild in advance so not everything can be compared to the past, but the amount of new not-bouncing visitors has almost doubled and conversions (of course!) follow the same path. While traditionally March and April were their best months, July is coming close.

Conversions via phone are currently not measurable but it’s easy to ask the person that handles them if an increase is visible (audible?). You could do this properly by asking those people if they visited the website before. Logging that somewhere would allow you to combine this data without to much hassle.

Now, don’t forget to visit De Pastorie yourself! Even if it is only for a drink on their terrace.

Or even better: if you like to receive an actionable optimization report for your site or launch a PPC campaign together to increase traffic: don’t hesitate and send me a message.

FireFox 3.5 Pagerank plugin

The upgrade to the new FireFox 3.5 causes the nice Live Pagerank plugin by Martin of raketforskning to be deactivated.

firefox-pagerank-add-on

Although his URL means “rocket science”, his site seems to be down so I wouldn’t expect an updated version too soon.

Luckily a nice guy named Daniel Olivares has created a new version which runs on FireFox 3.5.

If you own one or more sites the little number that appears in the FireFox status bar is an addiction. The Google Toolbar offers the same, but of course you don’t want the whole package and that’s why this add-on is so popular.

Edit: at the time of writing this new version worked, but it seems like it no longer does. Neither does the one downloadable on the official plugins site (although some users report it does, e.g. with firefox 3.7).

View specific JavaScript with Zend Framework

Because Zend Framework (and in this case also the MVC part) lets you choose how you structure your project, you may have doubted about where to place client-side JavaScript scripts.

icon_javascript

Personally, I place application-wide scripts in something like /media/js/application.js, but in many cases you have scripts that are only applicable to a certain view. Of course we want to avoid having a JavaScript file for each view somewhere in a general JS folder like /media/js.

Putting the JavaScript straight into the view also isn’t optimal since Zend_Layout can for instance put more HTML below it and client-side scripts should be right before the </body> tag.

I thought it would be nice to be able to have [viewname].js files inside the views/[controller] directories. E.g.:

/application
  /controllers
     BugController.php
  /views
     /bug
        index.phtml
        index.js

That makes development easier since your view-specific scripts are still as close to your view as possible, but separated in a .js file so your IDE/editor can parse them as JavaScript. In my case I thought it would also be nice if the .js file would be parsed like the view itself meaning that any variables assigned to the view can also be used in the JavaScript file.

The Zend_Controller_Action postDispatch() method provides a possibility to parse and include the client-side script into the inlineScript view helper where it belongs:

public function postDispatch()
{
    $request = $this->getRequest();
    $controllerName =  $request->getControllerName();
    $actionName =  $request->getActionName();
    foreach ($this->view->getScriptPaths() as $path) {
        $fileName = $controllerName . DIRECTORY_SEPARATOR
            . $actionName . '.js';
        if (file_exists($path . $fileName)) {
            $view = clone $this->view;
            $script = $view->render($fileName);
            $this->view->inlineScript()->appendScript($script);
        }
    }
}

As you can see, the regular view script is cloned so that the same information is passed to the JavaScript file.

The only thing you now need to do is subclass Zend_Controller_Action, paste in the code above and use that new class in your controllers:

class MyController extends My_Controller_Action {}

Happy JavaScripting!