在503页上使用Google Analytics(分析)
问题描述:
我使用清漆来缓存我们的页面。当我们得到一个503 - 这经常发生 - 我想在那里进行某种类型的页面跟踪。我想把GA代码放在那里。我似乎无法找到任何其他人的实例。有没有人做过这个?这样做是否存在某种违规行为?在503页上使用Google Analytics(分析)
答
对于清漆,您可以使用vcl_error包含您自己的回复(包含Google Analytics代码)。
编辑:我还没有测试任何这些。他们只是例子。
一个例子:
sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
if (obj.status == 503) {
synthetic {"
<html>
<head>
<title></title>
</head>
<body>
<h1>Error</h1>
<p>Something</p>
<!-- ANALYTICS CODE -->
</body>
</html>
"};
return(deliver);
}
}
另外,您可以通过使用vmod添加从文件系统自己的网页(包含与第3版标准* +)。
# Add this to the top of your config
import std;
# vcl_error
sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
if (obj.status == 503) {
set obj.http.error503 = std.fileread("/path/to/errors/503.html");
synthetic obj.http.error503;
return(deliver);
}
}
+0
你可以做“合成std.fileread(”/ path/to/errors/503.html“);”代替。 – mdrozdziel 2013-04-12 07:37:18
当你得到一个503页面时,用户会被重定向到不同的页面还是他看到相同的页面? – Eduardo 2012-07-17 00:36:08