global navigation

gagandeep_bhati
Rookie Contributor
gagandeep_bhati
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)?
6 REPLIES 6
mehdi_mohammadi
Not applicable
mehdi_mohammadi
Target the div and bind the link tracking function to each links using jQuery.
Highlighted

global navigation

son_hoang
Employee Emeritus
son_hoang
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.
mehdi_mohammadi
Not applicable
mehdi_mohammadi
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.
samrat_dsouza
Silver Contributor
Silver Contributor samrat_dsouza
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

global navigation

pallavi_roy
Silver Contributor
Silver Contributor pallavi_roy
Samrat , could you please elaborate more ?
samrat_dsouza
Silver Contributor
Silver Contributor samrat_dsouza
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