Rich-text Reply

static web page, multiple environment (dev/staging/prod)

Idan 06-09-16
Accepted Solution

static web page, multiple environment (dev/staging/prod)

Hi there,

our web site index.html is static, and I was wondering how can I enable working with different optimizely projects, each loaded in a different environment (dev/staging/prod). 

e.g. for dev, I'd like the html to load the optimizely snippet that belongs to the sandbox project

<head>
   <script src="https://cdn.optimizely.com/js/111111111.js"></script>"

</head>

 

wheares for prod environment, I would need 

<head>
   <script src="https://cdn.optimizely.com/js/2222222.js"></script>"

</head>

 

Other analytics tools that I've used with provide a different token per environment, but here it seems that for the static HTML page (which I have), I need some other manipulation.

 

any help would be appreciated,

Idan

 

 

Level 1

beckyhall 06-09-16
 

Re: static web page, multiple environment (dev/staging/prod)

I'm not positive that I understand your question. Each Optimizely project will have a unique snippet, and typically people will create a separate project for each environment. The experiments associated with a given project will only run on pages that include that project's snippet, so all you need to do to use different projects with different environments is to place the appropriate snippet in the head of the matching environment's code.

 

Unless you're saying there is some reason you can't do this?

-Becky
Idan 06-09-16
 

Re: static web page, multiple environment (dev/staging/prod)

Thanks for your reply.

Yes, the reason I cannot do that, is that I strive to keep the same static code regardless of the environment.
meaning, index.html should be the same static file in dev/QA/Prod. it may execute differnt logic, but the hard coded &lt;script src=""> that optimizely enforces, cannot be manipulated.
Level 1
beckyhall 06-09-16
 

Re: static web page, multiple environment (dev/staging/prod)

Putting the snippet directly in the head is usually best practice for performance reasons, but any way you can get one snippet in one environment and the other snippet in the other environment should work (appending with JS, injecting with tag manager, etc).
-Becky