• 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Are those links dynamically generated or are they hardcoded in the template file?

    Thread Starter StephenAlpha

    (@stephenalpha)

    Some are coded in the template files–and those I don’t have a problem with.

    The JS that are giving me grief are those that I try to add (in text view) to hyperlinked text in post and page, in a few places.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding Javascript to WordPress Post’ is closed to new replies.