How can you create different Google Analytics page views on HTML form submit, depending on values in the form?
-
The problem is the landing page can not be changed depending on the result, so I have to try and record the page views on the form page rather than the form success page.
-
Answer:
Google Analytics code is just JavaScript, so you can run the trackPageview function, and pass whatever value you like within form validation JavaScript that runs onSubmit. Something like this (assuming you are using the non-asynchronous code, and have already tracked a pageview when the form loaded): <form action="success.php" onsubmit="validateForm()"> <input type="checkbox" id="test" value="1"> </form>. <script> function validateForm(){ if(document.getElementById("test").checked=true){ pageTracker._trackPageview('/form/checked'); } else{ pageTracker._trackPageview('/form/not-checked'); } } </script>
Mike Wheeler at Quora Visit the source
Related Q & A:
- How can you create a different page in Wordpress?Best solution by WordPress
- How do i create a Yahoo web page?Best solution by iwebhostingplans.com
- How Can I Create an XML to Create a Menu?Best solution by Drupal Answers
- How do I create a new Wikipedia page?Best solution by wiki.answers.com
- How can I create a "Tag Page" on Tumblr?Best solution by uk.answers.yahoo.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.