dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: javascript event tracking not rendering

  1. #1
    Join Date
    Oct 2013
    Posts
    2

    javascript event tracking not rendering

    So I'm having a serious problem finding out the best way to solve this problem, I've checked numerous forum posts and tried several versions of the event tracking code for google and nothing seems to work.

    Basically I've built a site using the CMS Perch by edgeofmyseat.com and what my client has now asked for is a way of tracking the contact form and register your interest for submissions throughout the site. They don't need to know which page the form is submitted on they just need the overall submission numbers to check against advertising campaigns they run.

    I only know basic JavaScript and am really a Designer rather than a Developer but I know enough to implement code from outside sources. Perch works with it's own tags inside templates and I was told to simply paste in this code between the <perch:success></perch:success> tags of the temple for it to render when the form is submitted:

    <script type="text/javascript">
    _gaq.push(['_trackEvent', 'contact', 'enquiry', 'enquiry form',, false]);
    </script>

    When I try to verify the Goal in Google analytics I get this and no results even after having left it for 4 days:
    This Goal would have a 0% conversion rate based on your data from the past 7 days. Try a different set up.

    I figured that simply entering a _gaq.push code into the script tags may not have worked because I would have to call in a function, but even the code below doesn't work.

    <script type="text/javascript">
    $('#Enquiry-form').submit(function(event) {
    var _this = this;
    _gaq.push(
    // Queue the tracking event
    ['_trackEvent', 'contact', 'enquiry', 'enquiry form',, false]);
    });
    </script>

    I've also tried to pop in an onsubmit="_gaq.push(['_trackEvent', 'contact', 'enquiry', 'enquiry form',, false]);" into the <perch:form> tag but that doesn't seem the render in the browser.

    The form I'm testing this on is here:
    http://redcliffehomes.co.uk/contact-us.php

    Any ideas would be massively appreciated and let me know if you need any more information.

  2. #2
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774

  3. #3
    Join Date
    Oct 2013
    Posts
    2
    Quote Originally Posted by toicontien View Post
    Why not just have a special tracking code on the page that gets loaded as a result of the form submit?
    the only code like that I can find is this:

    <script>
    Y.use('node', function() {
    Y.on('domready', function() {
    Y.all('.form-block').each(function(n) {
    var d = n.getData('block-json');
    d = Y.JSON.parse(d);
    n.one('form').on('submit',function() {
    _gaq.push(['_trackEvent', d.formName + ' Submission', 'Form Submission', 'Submit']);
    });
    });
    });
    });
    </script>

    and for some reason I can't add a name to the <form> tag and I'm not sure why. I can't seem to add anything it so I can't reference the form name in script I would add the the page, do you know any other special tracking code? Or is there a way I can use the id instead of the name?

    I did say I am a Designer rather than a Developer this is all quite new to me!

  4. #4
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles