A/B Split Google Optimizer for WordPress (FILTER HOOKS)


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



Copy this code and paste it in your HTML
  1. //Custom Headers for A/B Split Landing Pages
  2. function insert_splittest_header() {
  3. if (is_page(8582)) { ?>
  4. <!-- Google Website Optimizer Control Script -->
  5. <script>
  6. function utmx_section(){}function utmx(){}
  7. (function(){var k='0785944995',d=document,l=d.location,c=d.cookie;function f(n){
  8. if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.indexOf(';',i);return escape(c.substring(i+n.
  9. length+1,j<0?c.length:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
  10. d.write('<sc'+'ript src="'+
  11. 'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'
  12. +'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='
  13. +new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
  14. '" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
  15. </script><script>utmx("url",'A/B');</script>
  16. <!-- End of Google Website Optimizer Control Script -->
  17. <!-- Google Website Optimizer Tracking Script -->
  18. <script type="text/javascript">
  19. var _gaq = _gaq || [];
  20. _gaq.push(['gwo._setAccount', 'UA-23025259-1']);
  21. _gaq.push(['gwo._trackPageview', '/0785944995/test']);
  22. (function() {
  23. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  24. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  25. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  26. })();
  27. </script>
  28. <!-- End of Google Website Optimizer Tracking Script -->
  29.  
  30. <?php } }
  31. add_action('wp_head','insert_splittest_header',0);
  32.  
  33.  
  34. // Customer Footer for final page - the 'thank you'
  35. function insert_B_footer () {
  36. if (is_page(9161)) { ?>
  37. <!-- Google Website Optimizer Tracking Script -->
  38. <script type="text/javascript">
  39. var _gaq = _gaq || [];
  40. _gaq.push(['gwo._setAccount', 'UA-23025259-1']);
  41. _gaq.push(['gwo._trackPageview', '/0785944995/test']);
  42. (function() {
  43. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  44. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  45. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  46. })();
  47. </script>
  48. <!-- End of Google Website Optimizer Tracking Script -->
  49. <?php } }
  50. add_action('wp_footer','insert_B_footer');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.