最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论