Adding Javascript to WordPress Post
-
I’ve googled and tried different things to solve what seems on the surface a simple matter, but which nonetheless has me totally stumped …
I am trying to track onclick event in my Google Analytics account, for which I’ve successfully inserted hyperlinks in select template files. The account is properly setup and the analytics code added to my template header at the appropriate place.
Here’ the Javascript code: onClick=”_gaq.push([‘_trackEvent’, ‘First Buy Link’, ‘Clicked First Buy Link’]);”
The problem I’m having is inserting this in a WordPress page/post hyperlink.
Some of the info I’ve come across suggest that it cannot be done in post and pages as a security measure in WordPress. I’m looking for a workaround—plugin or otherwise.
So far when I insert the JS in text view and save, I notice that WP removes it and places it before the “a” tag where it is not functional. Other times the code shows up on the published page in the browser.
Some clear direction would be appreciated. I am resourceful and can usually persevere to a solution.
The topic ‘Adding Javascript to WordPress Post’ is closed to new replies.