Posted By

Reiff on 03/27/14


Tagged

google wordpress Analytics simulation Javasctipt


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

fhenderson


Simulate a click with javascript for WordPress and GA


 / Published in: JavaScript
 

URL: http://snippets.reiffs.dk/simuler-et-view-af-en-side-med-javascript-onclick/

Simulates a click on a page with the name you put in the parameter in the onclick function.

  1. <input id="submit" onclick="trackpage('/kontaktudfyldt/')" type="submit" value="<?php _e('Send Email', 'framework') ?>" />
  2. <script type="text/javascript">
  3. // <![CDATA[
  4. var readytosubmit = false;
  5. function trackpage (track)
  6. {
  7. _gaq.push(['_trackPageview',track]);
  8. readytosubmit = !readytosubmit;
  9. setTimeout(clicksubmit(), 100)}
  10. function clicksubmit()
  11. {
  12. document.getElementById("submit").click();
  13. }
  14. // ]]>
  15. </script>

Report this snippet  

You need to login to post a comment.