Optimize
6.7K members online now
6.7K members online now
Learn how to create your first experiment and get tips on creating A/B, redirect, and multivariate tests.
Guide Me
star_border
Reply

Experiments with Dynamic Pages

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hey There,

 

Loving Optimize.

 

I have an app with a dynamic URL: `website.com/results/:id`, where the `:id` portion of the url changes, however everything that is on the /results page has the same basic structure, with a bit of dynamic content based on the `:id`.

 

Is it possible to create an experiment with a wildcard (`website.com/results/*`) domain?

1 Expert replyverified_user

Experiments with Dynamic Pages

Google Employee
# 2
Google Employee

Yes, this is possible using a URL regular expression matching rule: https://support.google.com/360suite/optimize/answer/6283424?hl=en

 

URL regex matches website.com/results/

or 

URL regex matches website.com/results/.*

 

should work.

Experiments with Dynamic Pages

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Jim,

 

Thanks for your answer, I really appreciate it!

 

So I implemented the RegEx, and it seemed to work as expected. The only other issue is that the page loads dynamic content after anywhere from 2-90 seconds. The issue that this is presenting is that the content to be changed by Optimize isn't available in the DOM until after it's been loaded.

 

Is the best practice here to set a `dataLayer` variable once the content is loaded? And then the optimize stuff would fire? If this is the case, then what's the best practice for reassigning that variable? dataLayer.pop()? I've been referencing this article and there's nothing about reassigning -- 

 

I also tried sending the `optimize.activate` event to GA with no luck there either.

 

Anyways, thanks for your time. I really appreciate it! 

Marked as Best Answer.
Solution
Accepted by topic author Jake H
December 2016

Experiments with Dynamic Pages

Google Employee
# 4
Google Employee

Once your new content loads and you are ready for Optimize to fire the experiment changes, you can trigger this by pushing an event to the dataLayer from the code on your page:

 

dataLayer.push({event: 'my_experiment_event'});

 

Then in Optimize you can configure the experiment to fire when that event occurs. On the experiment details page select the TARGETING tab and then edit where it says "Evaluate on page load". From there you can specify the name of the event you want to trigger the experiment (in my example it would be: my_experiment_event.

 

Experiments with Dynamic Pages

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

This was perfect. Thanks Jim! I guess I was mostly confused by the documentation because it wasn't quite clear how the event was to be sent with the custom event feature. But that cleared it right up, and now its working great. I really appreciate it!

Experiments with Dynamic Pages

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi,

This makes sense from a targeting point of view. However while setting up the experiment, i have to specify the complete url of the original page. I tried adding a regex, but it didnt work. e.g https://myfave.com/kuala-lumpur/collections/* 

Experiments with Dynamic Pages

Follower ✭ ✭ ✭
# 7
Follower ✭ ✭ ✭

Also learned something new!  Thank you!

Experiments with Dynamic Pages

Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭

Hi, I have a question about the dynamic URLs, can I use RegEx for original URL?

 

Which type experiment should I use, A/B test or Redirect test?

Experiments with Dynamic Pages

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

BUMP! Please answer if anyone knows a work around this. Thanks!

Experiments with Dynamic Pages

Visitor ✭ ✭ ✭
# 10
Visitor ✭ ✭ ✭

Anyone know if this possible?

 

I'm trying to implement a test sitewide with two different checkout scenarios on a eCommerce site. 

 

thanks!

John