beautypg.com

Google Website Optimizer v 1.0 The Techie Guide User Manual

Page 19

background image

19

The Techie Guide to Google Website Optimizer

Experiments with Dynamic Content

Let’s dig into the details.

Option 1 - Use a MVT experiment and custom JavaScript

Here is a proof of concept example that uses an

MVT style of experiment to test sections with

dynamic content. Suppose you have a section in

which there are three pieces of dynamic content.

Then, consider an alternative section variation for

this section:

Buy a %%product_name%% for the price

of %%product_price%% by clicking

here

Tokens (such as

%%product_id%%

) are to be replaced with dynamically generated content. When creating

your alternate versions, you might want to try:

For the price of only %%product_price%%, you can buy a %%product_name%%

by clicking here

Note that the second variation mentions the price before the product name. Now, the JavaScript that takes

advantage of these kinds of section variations would look like this:

The call to the utmx function, taking the arguments ‘variation-content’ and ‘Section1’ will return the section

template for the section named “Section1” that includes the %%’ed tokens, which are replaced with the

dynamic content. Note that the tokens in the script are server-side PHP code. This example uses

PHP, but any server-side system will work.

Please take note that visitors who have turned off JavaScript will see the default, unordered list of the

dynamically generated content.

Gotcha alert: Always escape any JavaScript special characters when setting up the variables, such as quotes.

Otherwise the JavaScript code will have errors.

Point to remember

There is no “best” solution for implementing

experiments with dynamic content. Each has its

pros and cons. Some developers will prefer option

1 and others will stick with option 2