22 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_INSERT_GA_FILTER_H_
23 #define NET_INSTAWEB_REWRITER_PUBLIC_INSERT_GA_FILTER_H_
34 namespace net_instaweb {
41 extern const char kGAJsSnippet[];
42 extern const char kAnalyticsJsSnippet[];
43 extern const char kAnalyticsJsIncreaseSiteSpeedTracking[];
44 extern const char kAnalyticsJsIncreaseSiteSpeedTrackingMinimal[];
45 extern const char kContentExperimentsJsClientUrl[];
46 extern const char kContentExperimentsNonNumericVariantComment[];
47 extern const char kContentExperimentsSetChosenVariationSnippet[];
48 extern const char kContentExperimentsSetExpAndVariantSnippet[];
49 extern const char kGASpeedTracking[];
63 virtual void StartElementImpl(
HtmlElement* element);
68 virtual const char*
Name()
const {
return "InsertGASnippet"; }
72 enum AnalyticsStatus {
76 kUnusableSnippetFound,
98 virtual void EndDocument();
101 void HandleEndScript(HtmlElement* script);
108 void RewriteInlineScript(HtmlCharactersNode* characters);
116 AnalyticsStatus FindSnippetInScript(
const GoogleString& s);
124 bool ShouldInsertExperimentTracking(
bool analytics_js);
126 bool StringLiteralMatches(StringPiece literal, StringPiece desired);
127 bool StringLiteralEndsWith(StringPiece literal, StringPiece desired);
130 Variable* inserted_ga_snippets_count_;
134 HtmlElement* script_element_;
136 bool added_analytics_js_;
138 bool added_experiment_snippet_;
148 bool increase_speed_tracking_;
153 bool seen_sync_ga_js_;
Definition: common_filter.h:47
static void InitStats(Statistics *stats)
Set up statistics for this filter.
Leaf node representing raw characters in HTML.
Definition: html_node.h:167
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
Definition: html_element.h:42
virtual void StartDocumentImpl()
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
ScriptUsage GetScriptUsage() const override
Definition: insert_ga_filter.h:69
Definition: insert_ga_filter.h:54
const char kGAExperimentSnippet[]
Visible only for use in tests.
ScriptUsage
Describes a filter's relationship with scripts.
Definition: html_filter.h:38
Definition: rewrite_driver.h:100
virtual const char * Name() const
The name of this filter – used for logging and debugging.
Definition: insert_ga_filter.h:68
Definition: html_filter.h:43
virtual void Characters(HtmlCharactersNode *characters)
HTML Events we expect to be in <script> elements.