Simulate a click with javascript for WordPress and GA


/ Published in: JavaScript
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.