How can I track clicks on global navigation (header , menu/sub-menus and footer) while avoiding coding for each link separately?
I understand this can be done by utag.link() for each link whereas the link tracking extension is deprecated and should not be used.
Is there a generic way to track all navigation links by default (by reading the label of the link or some other HTML attribute like id)?
Mehdi's recommendation is good but requires you know how to write jQuery selectors.
You can select all 'a' elements generically simply by using 'a' as your selector, but if your goal is to only select the navigational items you will have to get more detailed (but not as detailed as coding IDs for every item you want to track). Every site is different though and without direct examination of your page we wouldn't be able to recommend the exact selector for your use-case. I'd recommend contacting your account or deployment manager so we can look into this for you.
If you select all the 'a' elements then this can effect the performance of the page load. By using bit of javascript code you can help the performance of the page.
Agree with Mehdi.
I'd suggest to review the navigation elements and get selectors where required, using which, build a jQuery function to track assets clicked.
TIP: do not try to fire onClick, rather save it in a session cookie and read it on next pageLoad and fire it along with pageLoad tracking call. Benefits: no delay tracking no extra tracking calls.
Cheers
Samrat
Hi Pallavi
First create a function to save whatever values to pass in a cookie, onClick of global navigation.
Second, create a function that runs on every pageLoad to check for this cookie and if it exists pass it to GA/Adobe and reset it.
Thanks
Sam