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.
- 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.
- 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)
- Redirect the completed action to the node id that you just created, you can also use the clean url if enabled
- Copy the page.tpl.php file and name the copy page-node-#.tpl.php (# represents the node id of the actual redirect page).
- Paste your Yahoo! tracking code into the
- 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.