SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Google Analytics track form submissions - will this jquery work?..

    I have a form that captures users email addresses when they sign up for a enewsletter. I want to add this form submission into my google analytics and from what I have read the best way to do this is by tracking an event? I have added some jquery that I mashed together and I just want to know will this work? I added it today and I can only find out if it has truely worked by waiting 24 hours. I downloaded a program called fiddler (recommended in dot net magazine) to see tracking requests in action instead of waiting 24 hours but I can't see any of the field names displaying like AMF signup?

    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-8736163-1");
    pageTracker._trackPageview();
    } catch(err) {}

    $(document).ready(function() {
    $("#pre-book").attr("onSubmit", "pageTracker._trackEvent('Signup Forms','AMF Signup','Newsletter',2.0);");
    });

    </script>

  2. #2
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this didnt work.. can anyone shed some light on this for me?

  3. #3
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone know how to get this working??

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try
    Code:
    $(document).ready(function() {
        $("#pre-book").submit(function(){
            pageTracker._trackEvent('Signup Forms','AMF Signup','Newsletter',2.0);
        }
    });

  5. #5
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool thanks cramlibu will see if it works tomorrow!

  6. #6
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    unfortunately that didnt work...

    when I click on event tracking it shows 0 total events..

    what does the 2.0 do?

  7. #7
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool got it working, thanks for the help!
    This is the code that works:
    Code:
    $(function(){
        $("#pre-book").submit(function(){
            pageTracker._trackEvent('Signup Forms','AMF Signup','Newsletter');
    	})
    })

  8. #8
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Interesting, but could you not simply use the built-in conversion tracking they provide?

    Curious, but maybe I haven't understood your requirement well enough.

    - Vince

  9. #9
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you mean goals and funnels? the form doesn't send the user to another page so I can't set up a goal of reaching the "submit-complete.php" and track that.. is that what you meant by the built in conversion tracking?

    hey guys on another note on getting this event tracking data more specific is there a way of knowing if a submissions was invalid or valid? My form checks if the email is invalid first and if it is invalid it says "please enter a valid email"..

    Right now I think all the events being recorded are for every time someone clicks the submit button.. How can GA detect if it is a valid email submission?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •