Random Post Link
[resolved] Add google analytics even tracking? (2 posts)

  1. couchseats
    Posted 3 years ago #

    Is it possible to add the google code for event tracking
    typically you just add something like this into the <a href="url.com">

    onClick="_gaq.push(['_trackEvent', '', '',,, false]);"

    I tried doing that in random-post-link.php but got a syntax error

    any suggestions?



    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged/corrupted by the forum's parser.]

  2. Christopher Finke
    Design Engineer at Automattic
    Plugin Author

    Posted 3 years ago #

    You'd have to replace line 14 with something like this:

    printf('<a href="%s" onClick="_gaq.push([\'_trackEvent\', ... ]);">%s</a>', get_random_post_url(), $text);

    (Notice the backslashes before each apostrophe in your code.)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Random Post Link
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.