Richard Castera

Application Developer/Designer
  • Home
  • About
  • Projects
Google, Javascript, Marketing, Web Resources | No Comments | May 21, 2010

Google Analytics – How to manually Track Clicks on Outbound Links

You can use Google Analytics to track clicks on links that lead away from your site. Because links that lead away from your site are not automatically tracked, you will need to manually tag all outbound links you want to track. To do this, you’ll add some JavaScript customizations to your page and to the links you want to track.

  1. Set up Event Tracking in your Analytics Tracking code. This is a simple matter of adding the following line to the tracking code for your pages after the page tracking object is set up:
    var pageTracker = _gat._getTracker('UA-XXXXX-X');
    pageTracker._trackPageview();
    
  2. Add a JavaScript method in the head of your document to delay the outbound click by a fraction of a second. This delay will hardly be noticeable by the user, but it will provide the browser more time load the tracking code. Without this method, it’s possible that a user can click on the outbound link before the tracking code loads, in which case the event will not be recorded. Here’s what the JavaScript code in the section should look like (assuming you will use your own tracking code ID):
    <script type="text/javascript">
    function recordOutboundLink(link, category, action) {
      try {
        var pageTracker=_gat._getTracker("UA-XXXXX-X");
        pageTracker._trackEvent(category, action);
        setTimeout('document.location = "' + link.href + '"', 100)
      }catch(err){}
    }
    </script>
    
  3. Update your outbound links to call the new function without first following the link. For example, to log every click on a particular link to www.example.com, you would use the _trackEvent() method in the link’s tag:
    <a href="http://www.example.com" onClick="recordOutboundLink(this, 'Outbound Links', 'example.com');return false;">Trackable Link</a>
    

The example above uses the category label Outbound Links. This is a useful way to categorize all outbound links in the Event Tracking reports. It sets the specific name of the website as the second parameter in the call. With this structure in place, you could then see Outbound Links as one of the event categories and drill down to see which particular outbound links are the most popular. Be sure to use return false for the onClick handler, because without that statement the browser will follow the link before the recordOutboundLink method has a chance to execute.

For more information on using event tracking, see the Event Tracking Guide on Google Code.

Article Reference URL:
http://www.google.com/support/googleanalytics/bin/answer.py?answer=55527&cbid=-wlhzojb6oodb&src=cb&lev=index

Magento, My Thoughts, News, PHP, Web Resources | No Comments | May 17, 2010

Magento extensions and modern e-commerce

For an online retailer, choosing an e-commerce software platform is one of the most important decisions. Depending on the size of the business, the key requirements could vary from robustness and scalability critical for large retailers to the need for simplicity and flexibility for small store owners. Perhaps it is the ability to effortlessly meet the diverse needs of disparate audiences that has made Magento one of the fastest growing e-commerce applications globally. Already, the Magento e-commerce suite has carried out over US$25 billion in transactions via the 30,000+ merchants who rely on this platform, including some from the Internet Retailer Top 500 list. No wonder then that the platform continues to receive international acclaim, most recently from well known research organization Forrester Research which highlighted Magento as ‘unique’ among various e-commerce technology providers.

One of the key contributors to Magento’s rising popularity as the platform of choice is its ‘flexibility’ and the control that it puts in the hands of the online merchant. Unlike some of the other ‘closed’ or even open source e-commerce platforms, Magento does not place restrictions on business flows and processes. With over 1700 Magento extensions already available (and counting..), technology complements the business rather than business being shaped by the limits posed by technology.

Possibilities galore with Magento extensions

As the e-commerce and online marketing landscape evolves at frenetic pace, resulting in newer business models and novel marketing opportunities, online store owners need their technology to be as dynamic or risk being left behind. This is where the continuously expanding range of Magento extensions becomes invaluable.

Developers continue to enrich the application with powerful add-ons to fulfill even the not-so-obvious requirements of store owners. Presenting irrefutable proof of the value of the open source paradigm in e-commerce, these extensions help automate and optimize different business processes.

Characteristics of truly valuable Magento extensions

While new add-ons for the different Magento modules become available very regularly, some fundamental and seemingly obvious characteristics differentiate the really valuable extensions from the just OK ones. If you are looking for extensions for your business, run this simple 4-factor test.

  • Usefulness: An extension has to either help contribute to greater sales (revenues), build long-term customer engagement or improve operational efficiencies and effectiveness. Does the extension offer the features and functionality that will help you address your unique business needs or problems?
  • Cost-effectiveness: Is the price you pay for the add-on worth the value you expect to generate from using the extension?
  • Customizability: Can you customize your extension easily both in terms of front-end design as well as functionality to suit your specific needs?
  • User-friendliness: Is the extension easy to configure and use so that a store owner can focus on the business side of things? It should ultimately help save time, not add more work.

Epitomizing the above characteristics is the portfolio of extensions from aheadWorks, one of the largest Magento extensions development companies. The company’s range of free and paid-for add-ons, covers every aspect of the e-commerce process – back-end store administration, user experience, marketing and other operational aspects of the business.

Below, we briefly touch upon some of the most well-received Magento add-ons developed by the company:

Read the rest of this entry »
Apache, PHP | No Comments | May 4, 2010

Enable curl with XAMPP

cURL is disabled by default in your XAMPP installation. To enable it, you have to modify the php.ini files in your XAMPP folder. Follow the steps below to get it up and running.

  1. Locate the following files:
    C:\Program Files\xampp\apache\bin\php.ini
    C:\Program Files\xampp\php\php.ini
    C:\Program Files\xampp\php\php4\php.ini
    
  2. Uncomment the following line on your php.ini file by removing the semicolon.
    ;extension=php_curl.dll
    
  3. Restart your Apache server.
  4. Check your phpinfo if curl was properly enabled.
Apache, MySQL, PHP, Web Resources | 2 Comments | April 4, 2010

How to setup a local web server on your computer using XAMPP

Web development work should always be done locally. When developing a website, all the development work should be done on a local LAMP Stack environment installed on your computer. That way, the production time is greatly reduced and you can fully test your work before launching.

When you are completely done developing your project, the migration to the live server is seamless. Here are the simple steps to install a local server on your PC to easily develop websites.

This article applies to the installation on Windows 98, NT, 2000, 2003, XP and Vista, of Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql.

Installing XAMPP on your computer

  1. First, download XAMPP for Windows Installer
  2. Then run the installer on your computer and make sure that your Windows firewall unblocks Apache.
  3. Run the Apache administrator.
  4. Open your browser and go to http://127.0.0.1 – If all went well, a screen will appear where you can choose your language.
  5. Go to http://127.0.0.1/security/xamppsecurity.php and setup a password (it ill be used for your databases), and click on “Password Changing”.

Congratulations! You’re done! Now put your website’s files in a new directory under C:\xampp\htdocs\ (if you installed xampp in C:\xampp). For example: C:\xampp\htdocs\myproject\; and setup your databases using PHPMyAdmin located here http://127.0.0.1/phpmyadmin/.

Configuring Mod Rewrite

To finalize your installation, and make your development work much easier, go through the following steps to enable Mod Rewrite. This enables you to use fancy permalinks without the index.php appendage.

  1. Navigate to C:\xampp\apache\conf\httpd.conf
  2. Open up httpd.conf in notepad and look for this line:
    #LoadModule rewrite_module modules/mod_rewrite.so
    
  3. Uncomment it so that it reads:
    LoadModule rewrite_module modules/mod_rewrite.so
    
  4. Next, search for AllowOverride None and change it to AllowOverride All.
  5. Restart Apache by typing services.msc in either the command prompt or Start Search prompt in Vista.

Personalized Domain for your Local Environment

I’ve set my local environment to mimic my live environment as much as possible. For example, to access the local environment for my blog, I type this in my browser (http://richardcastera.dev). Here is how to set that up for each project:

  1. Navigate to C:\Windows\System32\drivers\etc\ and open the host file in a notepad editor. Make sure the following lines are written in the file:
    127.0.0.1 localhost
    ::1 localhost
    
  2. Now add the following line to access your website locally via the URL myproject.dev (or any other URL you’d like):
    127.0.0.1    myproject.dev
  3. Finally, open the file C:\xampp\apache\conf\extra\httpd-vhosts.conf in a notepad editor, and add the following lines:
          NameVirtualHost *:80
          <VirtualHost *:80>
          DocumentRoot “C:/xampp/htdocs”
          ServerName localhost
          </VirtualHost>
          <VirtualHost *:80>
          ServerName myproject.dev
          ServerAdmin webmaster@localhost
          DocumentRoot “C:\xampp\htdocs\myproject”
          </VirtualHost>
    

That’s it! Hope you enjoyed the post!

Drupal, PHP, Web Resources | 1 Comment | March 5, 2010

Drupal – Check if a User has a specific role

Here is a quick way to determine if a user has a specific role

<?php
  // Bring the user object into scope.
  global $user;
  // Check to see if $user has the administrator user role.
  if (in_array('administrator', array_values($user->roles))) {
    // Do something.
  }
?>
Drupal, Javascript, PHP, Web Resources | No Comments | March 4, 2010

Drupal – Adding Javascript to your module

When creating your own Drupal module, you may need to add some styling or Javascript to improve the usability of your module. Here is how to do it.

drupal_add_js(drupal_get_path('module', 'MODULE_NAME') . '/common.js');

Similarly you can add CSS to your module as well

drupal_add_css(drupal_get_path('module', 'MODULE_NAME') . '/styles.css');
Drupal, PHP, Web Resources | No Comments | March 3, 2010

Drupal – Use hook_form_alter() to set redirect path on the form

One popular use of this hook is to change the destination of a form submission. Here is how it is accomplished:

<?php
function YOURMODULE_form_alter($form_id, &$form) {
  switch ($form['#id']) {
    case 'node-form':
       if ($form['type']['#value'] == 'story') {
         $form['#redirect'] = 'new/url';
       }
     break;
  }
}
?>
  • Page 2 of 14
  • <
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • ...
  • 14
  • >
  • Premium Email Templates

    Social Profiles

  • Twitter
  • Facebook
  • LinkedIn
  • Digg
  • Google
  • GitHub

    Last Tweet

  • Beware the heat-seeking Nerf machine-gun coming to a cubicle near you http://om.ly/svHF #fb
  • Follow me
  • Archives

    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • September 2008
    • August 2008
    • July 2008
    • June 2008
  • Categories

    • AJAX
    • Apache
    • Books
    • Drupal
    • Ecommerce
    • Flash
    • Google
    • Javascript
    • jQuery
    • Magento
    • Marketing
    • Mootools
    • My Thoughts
    • MySQL
    • News
    • Photoshop
    • PHP
    • Prototype
    • SEO
    • Web Resources
    • Wordpress
  • My Favorites

    • 37 Signals
    • Andrew Warner
    • Chris Coyier
    • Chris Shiflett
    • Collis Ta'eed
    • Development Seed
    • Drupal
    • HubSpot
    • James Padolsey
    • Joel On Software
    • John Resig
    • jQuery
    • Kevin Rose
    • Life Hacker
    • Magento
    • Mashable
    • Matt Cutts
    • Matt Ryan
    • MySQL
    • NetTuts
    • Noupe
    • Photoshop Tutorials
    • PHP
    • Smashing Magazine
    • Tech Crunch
    • WoorkUp
    • Wordpress

2010 © Copyright. Richard Castera - All Rights Reserved.

Top