Forum Discussion
Katherine_G_106
Nimbostratus
Jul 08, 2009Google Analytics Injection iRules for Multiple Virtual Servers
Morning,
I have written iRules for 2 separate virtual servers that inject the GA code snippet with a different google id. When I hit the first virtual server (A) the code is injected properly. ...
Katherine_G_106
Nimbostratus
Jul 08, 2009Here is a sample of the code I am currently using.
when RULE_INIT {
set txt_texttoinsert "
"
}
when HTTP_REQUEST {
Don't allow data to be chunked
if { [HTTP::version] eq "1.1" } {
if { [HTTP::header is_keepalive] } {
HTTP::header replace "Connection" "Keep-Alive"
}
HTTP::version "1.0"
}
}
when HTTP_RESPONSE {
if { [HTTP::header Content-Type] starts_with "text/html" } {
if { [HTTP::header exists "Content-Length"] } {
set content_length [HTTP::header "Content-Length"]
} else {
set content_length 1000000
}
if { $content_length > 0 } {
HTTP::collect $content_length
}
}
}
when HTTP_RESPONSE_DATA {
set idx [string last "" [HTTP::payload]]
if { -1 == $idx } {
set idx [string last "" [HTTP::payload]]
}
if { -1 == $idx } {
set offset [HTTP::payload length]
} else {
set offset $idx
}
HTTP::payload replace $offset 0 $::txt_texttoinsert
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects