lua-resty-minami/google_analytics : Openresty library to build a google_analytics webserver
This library is considered passed testing and may change without notice.
This library requires a Openresty build, please take here as reference.
# nginx.conf
# library folder 'resty' dir
lua_package_path "/path/to/conf/?.lua;;";
# website.conf
location / {
...
header_filter_by_lua_file /path/to/conf/headerfilter.lua;
mirror /google_analytics;
mirror_request_body on;
}
location /google_analytics {
internal;
resolver 8.8.8.8 ipv6=off;
resolver_timeout 10s;
access_by_lua_file /path/to/conf/access.lua;
content_by_lua_file /path/to/conf/content.lua;
}
-- content.lua
-- write your google_anaytics UA-xxxxxxxxx-1 to here
-- local tid = "UA-111111111-1"
local tid =
local post_body = "v=1&t=pageview&tid=" .. tid .. "&uip=" .. ngx.var.remote_addr .. "&cid=" .. ngx.var.cookie_cid .. "&dp=" .. cookie_uri .. "&dr=" .. http_referer .. "&z=" .. ngx.var.msec
Minami (Nanqinlang) (南琴浪) https://sometimesnaive.org
personal work, for non-profit, Copyright (C) 2018 All rights reserved.
This library's License: GPL v3.
- the ngx_lua module: http://wiki.nginx.org/HttpLuaModule