Analytics
5.5K members online now
Understand information in your reports and troubleshoot reporting issues such as self-referrals, (not set) data, and inaccurate information
 
Guide Me
star_border
Reply

event label as variable

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I want to use a variable on the label of my event tracking code to get the page url or the page name.

Hello, I have a button on each product page, to track clicks on it. The product page template is a model, used to all products.

 

Here's my code now, I think isn't working:

 

<a href="/orcamento" onClick="ga('send', 'event', 'Click-orcamento', 'click', [URL]);">

 

All I want is to set the 'label' as the page url, so I can know what product was clicked.

How can I do that?

Thanks!

 

Re: event label as variable

Top Contributor Alumni
# 2
Top Contributor Alumni
HI Hugo
While you can easily do that with simple JavaScript or GTM you actually dont need to do this.

With every event page on which the event took place is automatically tracked (I am assuming this is a web page and not app). In your event report you can just add a secondary dimension "Page", that should do the trick for you.

Hope this helps.
Regards, Nik
LinkedIn  |   @nikhilparachure | My Blog

Re: event label as variable

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
can you show me the code please?

Ex: <a href="/orcamento" onClick="ga('send', 'event', 'Click-orcamento', 'click', [URL]);">

Re: event label as variable

Top Contributor Alumni
# 4
Top Contributor Alumni
Well should be something like
<a href="/orcamento" onClick="ga('send', 'event', 'Click-orcamento', 'click', window.location);">
But you really dont need it as i explained above.
Regards, Nik
LinkedIn  |   @nikhilparachure | My Blog