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. Then, without closing my browser, I connect to the next virtual server (B), the code from the irule assigned to A is getting injected into the payload for site B.
I am not testing for the existence of the GA code in the payload; the analysis people want this instantiated even if the GA script is already hardcoded on the page.
1. How can I make sure that the unique irule runs for each virtual server?
2. How can I make this more efficient, since I want it to go into every page? Would it be ok to move the setting of the variable for code injection to HTTP_RESPONSE or HTTP_RESPONSE_DATA?
Thanks!!!
-katherine
- Katherine_G_106
Nimbostratus
Here 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 }
- hoolio
Cirrostratus
That's correct. You could either move the variable declaration to another event other than RULE_INIT or use two different names. - mayur_108081
Nimbostratus
can anybody share the steps/guidelines to configure the same...?
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