Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Last active August 29, 2015 14:07
Show Gist options
  • Save steveosoule/5915c67084f36e417881 to your computer and use it in GitHub Desktop.
Save steveosoule/5915c67084f36e417881 to your computer and use it in GitHub Desktop.
Miva - Checkout A/B Test
<mvt:if expr="ISNULL g.ab_version AND ISNULL g.ab_flush">
<mvt:item name="customfields" param="Read_Basket('ab_version', g.ab_version)" />
</mvt:if>
<mvt:if expr="ISNULL g.ab_version">
<mvt:assign name="g.randomNumber" value="random(100)" />
<mvt:if expr="g.randomNumber GE 50">
<mvt:assign name="g.ab_version" value="'A'"/>
<mvt:else>
<mvt:assign name="g.ab_version" value="'B'"/>
</mvt:if>
</mvt:if>
<mvt:item name="customfields" param="Write_Basket('ab_version', g.ab_version)" />
<mvt:if expr="g.ab_version EQ 'A'">
<!-- Do "Version A" -->
<mvt:else>
<!-- Do "Version B" -->
</mvt:if>
<mvt:foreach iterator="order" array="admin_order:orders">
<mvt:item name="customfields" param="Read_Order(l.settings:order:id,'ab_image_version', l.settings:order:ab_image_version)" />
<mvt:item name="customfields" param="Read_Order(l.settings:order:id,'comboData', l.settings:order:comboData)" />
<mvt:if expr="l.settings:order:ab_image_version">
<mvt:if expr="l.settings:order:ab_image_version EQ 'single'">
<mvt:assign name="g.singleTotal" value="g.singleTotal + l.settings:order:total"/>
</mvt:if>
<mvt:if expr="l.settings:order:ab_image_version EQ 'multiple'">
<mvt:assign name="g.multipleTotal" value="g.multipleTotal + l.settings:order:total"/>
</mvt:if>
<mvt:if expr="l.settings:order:ab_image_version EQ 'single' AND l.settings:order:comboData">
<mvt:assign name="g.singleComboTotal" value="g.singleComboTotal + l.settings:order:total"/>
</mvt:if>
<mvt:if expr="l.settings:order:ab_image_version EQ 'multiple' AND l.settings:order:comboData">
<mvt:assign name="g.multipleComboTotal" value="g.multipleComboTotal + l.settings:order:total"/>
</mvt:if>
&mvt:order:date;,&mvt:order:id;,&mvt:order:ab_image_version;,<mvt:if expr="NOT ISNULL l.settings:order:comboData">combo</mvt:if>,&mvt:order:total;,<mvt:if expr="l.settings:order:ab_image_version EQ 'single'">&mvt:global:singleTotal;<mvt:else>&mvt:global:multipleTotal;</mvt:if>,<mvt:if expr="l.settings:order:ab_image_version EQ 'single'">&mvt:global:singleComboTotal;<mvt:else>&mvt:global:multipleComboTotal;</mvt:if><br>
</mvt:if>
</mvt:foreach>
// Log view for all versions
_gaq.push([
'_trackEvent',
'AB Test - Product Page',
'AB Test - Product Page - View',
null,
true
]);
// Log specific version (i.e. Control, Blue Sign Up Button, Orange Sign Up Button)
_gaq.push([
'_trackEvent',
'AB Test - Product Page',
'AB Test - Product Page - ' + version,
null,
true
]);
// If there is a transaction, CTA, or goal to be tracked (i.e. Completed Sign Up)
$('form').on('submit', function(){
_gaq.push([
'_trackEvent',
'AB Test - Product Page',
'AB Test - Product Page - ' + version + ' - ' + transaction_or_goal,
null,
true
]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment