Newbie adding GA event tracking. Am I doing it correctly?
-
I am attempting to add GA event tracking to my posts so that I can track which of my affiliate links are being clicked on the most and compare image clicks versus text link clicks etc.
I am very new to wordpress and html in general, so I may be making errors.
To add the event tracking to a post I
1) Went to ‘edit post’ and then went into the html editor.
I then found the image link that I wanted to track.The original code looked like this:
<a href="https://www.roguefitness.com/rogue-fight-shorts.php?a_aid=4f01256aac669&a_bid=55639019"><img class="size-medium wp-image-52 aligncenter" title="Rogue Fitness' top selling CrossFit shorts" src="https://www.crossfitclothing.org/wp-content/uploads/2011/12/fight-shorts-front_1-199x300.jpg" alt="" width="199" height="300" /></a>
I then altered it to this:
<a href="https://www.roguefitness.com/rogue-fight-shorts.php?a_aid=4f01256aac669&a_bid=55639019" onclick="_gaq.push(['_trackEvent', 'affiliate links' , 'text' , 'rogue shorts' ]);" ><img class="size-medium wp-image-52 aligncenter" title="Rogue Fitness' top selling CrossFit shorts" src="https://www.crossfitclothing.org/wp-content/uploads/2011/12/fight-shorts-front_1-199x300.jpg" alt="" width="199" height="300" /></a>
I then went reverted to the visual editor and it visually looked the same (which I thought was a good sign). I then went back into html and it had CHANGED to the following:
<a onclick="_gaq.push(['_trackEvent', 'affiliate links' , 'text' , 'rogue shorts' ]);" href="https://www.roguefitness.com/rogue-fight-shorts.php?a_aid=4f01256aac669&a_bid=55639019"><img class="size-medium wp-image-52 aligncenter" title="Rogue Fitness' top selling CrossFit shorts" src="https://www.crossfitclothing.org/wp-content/uploads/2011/12/fight-shorts-front_1-199x300.jpg" alt="" width="199" height="300" /></a>
That is, the event code had been moved to BEFORE the url. Why did that happen.
I did this 24 hours ago, and then checked it. Generic unique event IDs had shown up, but no events had shown up for the label and category I had specified (and I clicked on it a few times just to make sure there would be events).
Two questions then:
1) Can someone please tell me what I have done wrong?
2) Why is wordpress automatically moving the event code in front of the url?Really appreciate your help!
- The topic ‘Newbie adding GA event tracking. Am I doing it correctly?’ is closed to new replies.