I'm trying to track click events in our 2 level drop down category navigation menu - located in the header.
All I'm trying to do is add some attributes to the <a href>
tags but this is proving to be harder than it sounds. I can't figure out where the $_menu
variable referenced in topmenu.phtml
is coming from. (any ideas?) I've found 2 solutions to the this problem that only seem OK and don't think either is best practice.
Option 1
Use an observer to intercept and modify the HTML.. This is roughly what the Anowave Tag Manager Module does.
Option 2
Use this example to create a fully custom top menu.. which exactly what's there already with some extra <a href>
attributes.
Thoughts
Option 2 requires create pretty redundant code because whatever is there is 99.9% good.. I'm just trying to include an attribute like data-value='category name'
etc.
ANSWER NOTES
Both @sander & @denisa posted answers that solved my problem. However, as @denisa mentioned, you need to know if you're using using the newer RWD template or the older template. I was using a newer install of Magento but and Non-RWD template. Once you know this, use either @denisa's answer or @sander's