Permalink
Browse files

setChosenVariant was a typo for setChosenVariation

Fixes experiment reporting for classic ga.js

Fixes #1288
  • Loading branch information...
jeffkaufman authored and crowell committed Apr 5, 2016
1 parent 6b9b59c commit 65067523faf34833cfda8ae5c5e10b5f7ba5497f
@@ -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:
@@ -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:
@@ -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 {
@@ -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());

@@ -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());
@@ -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);
@@ -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);
@@ -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());
@@ -785,7 +785,7 @@ TEST_F(InsertGAFilterTest, AsynchronousGAContentExperimentFlush) {
kContentExperimentsJsClientUrl,
"\"></script><script>",
StringPrintf(
kContentExperimentsSetChosenVariantSnippet,
kContentExperimentsSetChosenVariationSnippet,
"456", "123")).c_str(),
kGaId);

@@ -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[];

Submodule src deleted from e7390f

0 comments on commit 6506752

Please sign in to comment.