Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
setChosenVariant was a typo for setChosenVariation
Browse files Browse the repository at this point in the history
Fixes experiment reporting for classic ga.js

Fixes #1288
  • Loading branch information
jeffkaufman authored and crowell committed Apr 21, 2016
1 parent 6b9b59c commit 6506752
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions net/instaweb/rewriter/insert_ga_filter.cc
Expand Up @@ -69,7 +69,7 @@ namespace net_instaweb {
//
// ga.js + content experiments:
// <script src="kContentExperimentsJsClientUrl"></script>
// <script>kContentExperimentsSetChosenVariantSnippet
// <script>kContentExperimentsSetChosenVariationSnippet
// kGAJsSnippet</script> [ possibly existing ]
//
// analytics.js + content experiments:
Expand Down Expand Up @@ -140,8 +140,8 @@ extern const char kContentExperimentsJsClientUrl[] =
// When using content experiments with ga.js, after /cx/api.js has loaded and
// before ga.js loads you need to call this. The first argument is the
// variant id, the second is the experiment id.
extern const char kContentExperimentsSetChosenVariantSnippet[] =
"cxApi.setChosenVariant('%s', '%s');";
extern const char kContentExperimentsSetChosenVariationSnippet[] =
"cxApi.setChosenVariation('%s', '%s');";

// When using content experiments with analytics.js, after ga('create', ..._)
// and before ga('[...].send', 'pageview'), we need to insert:
Expand Down Expand Up @@ -296,7 +296,7 @@ void InsertGAFilter::EndDocument() {
InsertNodeAtBodyEnd(cxapi);

experiment_snippet = StringPrintf(
kContentExperimentsSetChosenVariantSnippet,
kContentExperimentsSetChosenVariationSnippet,
driver()->options()->content_experiment_variant_id().c_str(),
driver()->options()->content_experiment_id().c_str());
} else {
Expand Down Expand Up @@ -516,7 +516,7 @@ void InsertGAFilter::HandleEndScript(HtmlElement* script) {
if (!postponed_script_body_.empty()) {
DCHECK(script == script_element_);
GoogleString snippet_text = StringPrintf(
kContentExperimentsSetChosenVariantSnippet,
kContentExperimentsSetChosenVariationSnippet,
driver()->options()->content_experiment_variant_id().c_str(),
driver()->options()->content_experiment_id().c_str());

Expand Down
10 changes: 5 additions & 5 deletions net/instaweb/rewriter/insert_ga_filter_test.cc
Expand Up @@ -375,7 +375,7 @@ TEST_F(InsertGAFilterTest, ExperimentGaJsCx) {
kContentExperimentsJsClientUrl,
"\"></script>").c_str(),
"",
StrCat(StringPrintf(kContentExperimentsSetChosenVariantSnippet,
StrCat(StringPrintf(kContentExperimentsSetChosenVariationSnippet,
"456", "123"),
StringPrintf(kGAJsSnippet, kGaId, "test.com",
kGASpeedTracking)).c_str());
Expand Down Expand Up @@ -528,7 +528,7 @@ TEST_F(InsertGAFilterTest, SynchronousGAContentExperiment) {
kContentExperimentsJsClientUrl,
"\"></script><script>",
StringPrintf(
kContentExperimentsSetChosenVariantSnippet,
kContentExperimentsSetChosenVariationSnippet,
"456", "123")).c_str(),
kGaId);
ValidateExpected("extend sync ga.js for content experiment", input, output);
Expand Down Expand Up @@ -567,7 +567,7 @@ TEST_F(InsertGAFilterTest, AsynchronousGAContentExperiment) {
kContentExperimentsJsClientUrl,
"\"></script><script>",
StringPrintf(
kContentExperimentsSetChosenVariantSnippet,
kContentExperimentsSetChosenVariationSnippet,
"456", "123")).c_str(),
kGaId);
ValidateExpected("extend async ga.js for content experiment", input, output);
Expand Down Expand Up @@ -763,7 +763,7 @@ TEST_F(InsertGAFilterTest, ExistingGaJsContentExperimentNoCloseAnything) {
kContentExperimentsJsClientUrl,
"\"></script>"
"<script>",
StringPrintf(kContentExperimentsSetChosenVariantSnippet,
StringPrintf(kContentExperimentsSetChosenVariationSnippet,
"456", "123"),
StringPrintf(kGAJsSnippet, kGaId, "test.com",
kGASpeedTracking)).c_str());
Expand All @@ -785,7 +785,7 @@ TEST_F(InsertGAFilterTest, AsynchronousGAContentExperimentFlush) {
kContentExperimentsJsClientUrl,
"\"></script><script>",
StringPrintf(
kContentExperimentsSetChosenVariantSnippet,
kContentExperimentsSetChosenVariationSnippet,
"456", "123")).c_str(),
kGaId);

Expand Down
2 changes: 1 addition & 1 deletion net/instaweb/rewriter/public/insert_ga_filter.h
Expand Up @@ -42,7 +42,7 @@ extern const char kAnalyticsJsSnippet[];
extern const char kAnalyticsJsIncreaseSiteSpeedTracking[];
extern const char kAnalyticsJsIncreaseSiteSpeedTrackingMinimal[];
extern const char kContentExperimentsJsClientUrl[];
extern const char kContentExperimentsSetChosenVariantSnippet[];
extern const char kContentExperimentsSetChosenVariationSnippet[];
extern const char kContentExperimentsSetExpAndVariantSnippet[];
extern const char kGASpeedTracking[];

Expand Down
1 change: 0 additions & 1 deletion third_party/gflags/src
Submodule src deleted from e7390f

0 comments on commit 6506752

Please sign in to comment.