How to add Yahoo! Tracking Code to your Drupal Site

How to add Yahoo! Tracking Code to your Drupal Site

More and more of our clients are wanting to track their site metrics from more than just google and since there aren't really any great modules for adding the Yahoo! tracking code; I thought I'd share exactly how I went about adding them. The problem is that if I simply place the tag on the page.tpl.php file then I get the code going site wide and if it's a conversion code, I only need it to trigger for certain pages. We tried creating individual pages and then placing the code in the body, but the problem is the Yahoo! code must be placed into the tags. So, here's a simply way to get your Yahoo! conversion codes on the pages you need them.
  1. Create a new conversion page in Drupal and call it what you like, we used Thank You, but you could do conversion or really whatever you like.
  2. Find the node id for the page your created, you'll need it for redirection upon completion of your desired action. (ie. shopping cart checkout, filling out a webform and so on)
  3. Redirect the completed action to the node id that you just created, you can also use the clean url if enabled
  4. Copy the page.tpl.php file and name the copy page-node-#.tpl.php (# represents the node id of the actual redirect page).
  5. Paste your Yahoo! tracking code into the tags of your site, I put mine right before the closing head tag and save your file
  6. Upload the new file into your sites theme folder (where your page.tpl.php file is located) and then be sure to flush the theme registry cache.
Now your tracking code will be located in the head tag as required by Yahoo!

Related Posts

How to Set Up PPC Conversion Tracking in Drupal

Colin
Read more

The Best Gravity Forms Google Analytics Tracking How To?

Tom McCracken
Read more

How to Create a QR Code for Your Website in 5 Simple Steps

Litany Brown
Read more

Election Time is Here and Yahoo! Wants Your Opinion

Chris Sloan
Read more

Yahoo Buys Tumblr - Commence Wailing

Julie Miller
Read more

Synchronize one drupal site with another using Drush

Dustin Currie
Read more