javascript - Tracking AJAX-based forms with Google Analytics Goals - Stack Overflow

I'm developing sites using a content management system, features are added via 3rd party modules w

I'm developing sites using a content management system, features are added via 3rd party modules which is much easier for designers like myself. However, I'm a bit perplexed at the moment.

I have an AJAX-based contact form, so there is no page-load upon submission. However, I do have access to HTML templates for each step (Input page, Form submitted, and the email that is sent).

I did some research on the GA.js library and it seems like I'd want to use the _trackPageView function. I cobbled some code together based upon threads in the GA Help group, but I've been monitoring the account for 2days now (while submitting test forms ~5+ times per day) but I am not seeing the goal being pleted, nor am I seeing the 'dummy page' show up under my Top Content list (fully expanded). The code I'm using is the following:

/script tag/

    try {
        var pageTracker = _gat._getTracker("UA-#####-##");
        pageTracker._trackPageview(/formplete.html);
    } 
    catch(err) {}
/close script/

The goal URI is setup as Head Match and uses the value /formplete.html it is active, and the site is tracking. Any thoughts?

I'm developing sites using a content management system, features are added via 3rd party modules which is much easier for designers like myself. However, I'm a bit perplexed at the moment.

I have an AJAX-based contact form, so there is no page-load upon submission. However, I do have access to HTML templates for each step (Input page, Form submitted, and the email that is sent).

I did some research on the GA.js library and it seems like I'd want to use the _trackPageView function. I cobbled some code together based upon threads in the GA Help group, but I've been monitoring the account for 2days now (while submitting test forms ~5+ times per day) but I am not seeing the goal being pleted, nor am I seeing the 'dummy page' show up under my Top Content list (fully expanded). The code I'm using is the following:

/script tag/

    try {
        var pageTracker = _gat._getTracker("UA-#####-##");
        pageTracker._trackPageview(/formplete.html);
    } 
    catch(err) {}
/close script/

The goal URI is setup as Head Match and uses the value /formplete.html it is active, and the site is tracking. Any thoughts?

Share Improve this question edited Aug 13, 2009 at 21:46 skaffman 404k96 gold badges824 silver badges775 bronze badges asked Aug 13, 2009 at 21:44 SilentBobSCSilentBobSC 4351 gold badge4 silver badges9 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

You have a syntax error in your JavaScript code. You must wrap the virtual URI in quotes since function _trackPageview expects a string as its argument.

pageTracker._trackPageview("/formplete.html");

For avoiding similar issues in the future, get an IDE that highlights syntax errors or check Firefox's Error Console for any problems.

In the place where I've used this style of tracking I notice two difference between what I have and what you have.

First, at the top of the page, I've called

pageTracker._initData();
pageTracker._trackPageview();

in addition to what you have. In my case that tracks the main page load before the secondary (ajax) call occurs.

Then when I do the GA call

pageTracker._trackPageview('/virtual/name_i_gave_the_call')

I have the virtual name in quotes, not just bare in the parens as you have it. Not sure which (if either) of these differences may help you, but it is working for me.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745234643a4617832.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信