admin管理员组文章数量:1415484
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 badges2 Answers
Reset to default 6You 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.
本文标签: javascriptTracking AJAXbased forms with Google Analytics GoalsStack Overflow
版权声明:本文标题:javascript - Tracking AJAX-based forms with Google Analytics Goals - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745234642a2648978.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论