There may be a time when you want to only show an experience based on a certain window dimension to desktop and laptop users
The following example will illustrate the use of a template in the form of a Campaign Variation.
- Set your Campaign Variation Trigger to match on HTML pages by using Content-type: text/html or an HTML element such as a doctype or </body>. Optionally also use additional Triggers accordingly.
- Inject a code block at or near the bottom of the page like the following:
- Update the first three variables values as desired.
var minwidthpx = 1159;
var minheightpx = 0;
var minutes = 525960; /* 525960 is 1 year expiration. change to 30 for session expiration */ - Add the Campaign Variation to your campaign
- Set the Trigger(s) in your Campaign to include:
Cookie: (contains) sswnd=1
- Copy this template and repeat this process for other window dimensions in other Campaigns as needed.
Notes
The approach is that the Campaign Variation code will check on every new page load and update the cookie. On each subsequent page load the updated cookie will be passed to the server and the Trigger will evaluate it. An adjustment to this script to only create the cookie once per visit can be made if that is a requirement.
If the page is dynamic on the client (such as a SPA site), a Client Side Variation could be used to check the window dimension cookie with every URL change.
This approach is meant for Desktop users since resizing a window is not an option with Tablets and Mobile devices. Please use Mobile Audiences to target those users based on screen size.
Caution
Do not use a singular counting method that only counts in each Variation Group when the user window size meets the required dimension as the split will likely be uneven. Typically you would leave the default counting for one or more variations in your Variation Group.
Other Metrics
Do consider additional metrics for:
- When the dimension is met (EventTrack in the script code)
- When the cookie is met (sswnd=1, a Metric that has the same Cookie Trigger)