====== Insert Google Analytics Script when HTTP Response ====== * This aFleX collects the HTTP response and insert Google Analytics script before ===== Requirement ===== * Service Type: HTTP / HTTPS ===== Code ===== # jal.20140421: this aFleX collects the HTTP response and insert google analytics script before when HTTP_REQUEST { # remove "Accept-Encoding" header to make sure server doesn't send compressed response # (this is done automatically in Rel 2.6.1 and later) if { [HTTP::header exists "Accept-Encoding"] } { HTTP::header remove "Accept-Encoding" } } when HTTP_RESPONSE { # check Response Code and Content-Type to avoid unnecessary collects if { [HTTP::status] equals "200" && [HTTP::header "Content-Type"] contains "text/html" } { HTTP::collect } } when HTTP_RESPONSE_DATA { set clen [HTTP::payload length] regsub -all "" [HTTP::payload] " " newdata # Replace response data from 0 to old data length with new data. HTTP::payload replace 0 $clen $newdata HTTP::release }