- Optimizely X Web Experimentation
- Optimizely X Web Personalization
- Optimizely X Web Recommendations
his article will help you:
- Implement behavioral targeting across different origins (subdomains or protocols) of your site
An “origin” is a combination of a specific hostname, protocol, and port on your site. By default, events that you track in Optimizely can only be used to target changes on the same origin. So when the snippet is running on https://shop.example.com, it can access events that were generated on https://shop.example.com, but it cannot access events that were generated on:
What if you want to run an experiment on the secure origin https://shop.example.com, targeting browsing behavior on the unsecure origin http://shop.example.com? Or what if you want to target based on reading activity on http://blog.example.com?
Enable cross-origin targeting to track events across origins.
Enable cross-origin targeting
Navigate to Settings > Implementation. Scroll down to list the domains where you want to Optimizely to run.
Enter the URL where events should be tracked. Then, use the dropdown to target specific origins or groups of origins. Note that unlike Experiment URL targeting, the value matched with the pattern is specifically the "origin" portion of the URL, not the whole URL. There are several ways to specify origin patterns:
This includes origins like http://example.com, https://shop.example.com, https://shop.example.com:80, and http://example.computer.info. As shown with the last example, this can result in data being shared with other top-level and second-level domains.
This includes all of example.com when accessed via the secure https protocol. If you do not terminate the regular expression with your domain followed by the $ character, then this can result in data being shared with other top-level and second-level domains.
Use the URL Match Validator to check that your targeting matches the URLs you expect. Note that you can check full URLs including path, querystring, and hash, but those portions of the URL are ignored by the match pattern.
Then, click Save.
If you expect visitors to cross either domains or top-level domains, consider using the waitForOriginSync API.
Events can be targeted across origins only for the current Optimizely User ID, which is stored in the
optimizelyEndUserId cookie. Since browsers prevent sharing cookies across domains (e.g. example.com, anotherexample.com) and across top-level domains (e.g. example.com, example.net), Optimizely is unable to set consistent user IDs across such domains.
You will need to manually sync the
optimizelyEndUserId cookie across domains, using other means, in order for cross-domain targeting to work.