Rich-text Reply

How to include Django template variables and template tags in an Optimizely experiment?

alagappanr 06-02-16

How to include Django template variables and template tags in an Optimizely experiment?

I would like to create different variations of my page using Optimizely. My site uses Django and has Django template variables and tags.

I tried using the Optimizely editor to modify my page and included conditional statements. But it doesn't seem to consider them. 

 

Is it because Django variables are rendered from the server and it cannot be controlled through JavaScript? 

 

How can I create variations in Optimizely which can use Django variables and tags?

AllisonR 06-03-16
 

Re: How to include Django template variables and template tags in an Optimizely experiment?

Based on a user's response to this stackoverflow thread it doesn't seem like this will work: 

 

You can't use Django's template tags from your Javascript code... All the Django variables and logic stop existing after the template has been rendered and the HttpResponse has been sent to the client. At that moment when Javascript executes, the client (browser) has no notion the variables you rendered the template with (such as "form")...

 

Instead, to test two entirely different templates within Optimizely, I recommend creating two versions of your site (i.e. www.example.com and www.example.com/v2) and running a redirect experiment. Instructions for setting up a redirect experiment are here

 

Hope this helps!

 

 

Best,

Allison
Sr. Technical Support Engineer
Optimizely | EMEA

 

Allison
Sr. Technical Support Engineer
Optimizely | EMEA
Optimizely