- Joined
- May 17, 2015
- Messages
- 276
- Likes
- 379
- Degree
- 1
Ok, so I'm setting up Google Analytics tracking for my affiliates and I'm trying to be tricky with tracking my Sidebar Adverts. As a result I'm stuck.
I'm following this way of setting it up
www.matthewwoodward.co.uk/tutorials/how-to-track-anything-with-google-analytics/
Essentially I'm following this format when tracking clicks.
I replace the 3 values:
However, I have some sidebar adverts that I also want to track and I'm looking to implement some code that autofils the 'label' section with the page URL it is displayed on.
The tracking code looks something like this
However, when I put it live and inspect the element, it has put <?php echo $_SERVER['REQUEST_URI']; ?> a text and not recognised the code.
OR it doesn't even recognize the final " at the end which means the link doesn't even show up :/
I'm using Wordpress. This is in the Main Sidebar. The link is in a Text widget.
I'm stumped.
Any help is appreciated.
Cheers
I'm following this way of setting it up
www.matthewwoodward.co.uk/tutorials/how-to-track-anything-with-google-analytics/
Essentially I'm following this format when tracking clicks.
onclick="_gaq.push(['_trackEvent', 'category', 'action', 'label']);"
I replace the 3 values:
- Category – The category/type of event, e.g. Affiliate Click
- Action – Give the action a name, eg click (I use affiliate programme name here)
- Label – Anything else you want to include (I use the page URL)
onclick="_gaq.push(['_trackEvent', 'Affiliate', 'Amazon', '/best-widgets/']);"
The full link would look something like this:
<a href="https://mysite.com/go/widgets" target="_blank" rel="nofollow" onclick="_gaq.push(['_trackEvent', 'Affiliate', 'Amazon', '/best-widgets/']);">Blue Wigets</a>
That by itself is simple.
However, I have some sidebar adverts that I also want to track and I'm looking to implement some code that autofils the 'label' section with the page URL it is displayed on.
The tracking code looks something like this
onclick="_gaq.push(['_trackEvent', 'Affiliate', 'Amazon', '<?php echo $_SERVER['REQUEST_URI']; ?>
']);" However, when I put it live and inspect the element, it has put <?php echo $_SERVER['REQUEST_URI']; ?> a text and not recognised the code.
OR it doesn't even recognize the final " at the end which means the link doesn't even show up :/
I'm using Wordpress. This is in the Main Sidebar. The link is in a Text widget.
I'm stumped.
Any help is appreciated.
Cheers