Skip to content

Instantly share code, notes, and snippets.

@openjck
Last active August 29, 2015 14:18

Revisions

  1. openjck renamed this gist Apr 7, 2015. 1 changed file with 0 additions and 0 deletions.
  2. openjck created this gist Apr 7, 2015.
    18 changes: 18 additions & 0 deletions Example: Avoiding FOUC with the Optimizely API
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    {# Randomly determine if the new heading should be shown #}
    {% set show_new_heading = random_boolean() %}

    {% if show_new_heading %}
    <h1>The Best Documentation Around</h1>
    {% endif %}

    <script>
    window['optimizely'] = window['optimizely'] || [];

    {% if show_new_heading %}
    // Bucket visitor into the "New Heading" Optimizely variation for reporting
    window['optimizely'].push(['bucketVisitor', 555555, 123456]);
    {% else %}
    // Bucket visitor into the baseline Optimizely variation for reporting
    window['optimizely'].push(['bucketVisitor', 555555, 654321]);
    {% endif %}
    </script>