我正在尝试将分析事件跟踪添加到onclick事件中,以便在表单上提交输入.
我尝试了多个不同的例子,并引用了几个不同的SO帖子来达到这一点.我可以让onclick提交表单或触发跟踪事件,但不能同时触发.
第一个例子:(将表单+日志提交到控制台,但不会触发事件)
<!-- Analytics tracking code -->
<form action="test.php" id="form" method="post">
<input type="text" name="name" id="name">
<!-- Submits form + logs to console but doesn't fire event -->
<input type="submit" name="submit" value="Submit" onclick="
var _this = this;
_gaq.push(
['_trackEvent', 'Forms', 'Submit', 'Home Contact'],
function() {
console.log('submitting');
$(_this).parents('form').submit();
}
);
">
</form>
Run Code Online (Sandbox Code Playgroud)
第二个例子:(触发事件+日志到控制台,但不提交表单)
<!-- Analytics tracking code -->
<form action="test.php" id="form" method="post">
<input type="text" name="name" id="name">
<!-- Fires event + logs to console but doesn't submit form -->
<input …Run Code Online (Sandbox Code Playgroud) 我在apache服务器上设置了一个站点,其中桌面站点位于/ public_html,移动站点位于public_html/mob中
我正在尝试设置一个.htaccess rewriterule来将用户发送到/ public_html中的index.php文件,如果他们访问/ mob文件夹的话.我目前的重写规则,在mob子文件夹中是:
RewriteRule ^(/)?$ ../index.php
Run Code Online (Sandbox Code Playgroud)
我可以在mob子目录中加载相同的文件:
RewriteRule ^(/)?$ index.php
Run Code Online (Sandbox Code Playgroud)
但是我似乎无法让网站从父目录(public_html)加载index.php文件.
尝试在浏览器中加载http://www.domain.com/mob时,我会收到:
Bad Request
Your browser sent a request that this server could not understand.
Run Code Online (Sandbox Code Playgroud)
这个重写程序在我们的开发服务器上运行良好,但在我们的实时环境中不起作用.
/ public_html/mob文件夹中的.htaccess文件如下:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(/)?$ ../index.php [L,QSA]
Run Code Online (Sandbox Code Playgroud)
当达到index.php时,移动设备检测脚本决定是否从桌面或移动站点加载内容.
我目前在几个不同的Google帐户中有大约100个Google Analytics网站,一个帐户拥有每个网站的完全权限.如果可能,我希望避免将Google服务帐户的权限手动添加到每个分析配置文件.
尝试使用$ delegate_email参数模拟用户时,出现以下异常:
GAPI: Failed to authenticate user. Error: "{
"error": "unauthorized_client",
"error_description": "Unauthorized client or scope in request."
}
Run Code Online (Sandbox Code Playgroud)
我在其他地方读过有关需要使用Google Apps管理控制台"将域范围权限委派给服务帐户"的信息.但是,我们根本没有Google Apps.有没有办法解决?
tl; dr 是否有办法使用服务帐户获取对Google Analytics的只读访问权限并假冒没有Google Apps的用户?
.htaccess ×1
analytics ×1
apache ×1
google-api ×1
javascript ×1
jquery ×1
mod-rewrite ×1
onclick ×1
php ×1