This article will help you target visitors who have been on a specific page of your website. For example, visitors who have already seen your pricing page or people who already visited your promo page.
Please note, in this tutorial we'll use custom properties.
Also, this tutorial will only work for people who've been on the page after the implementation of the script.
Script preparation
To make this work, we need to embed a new script that will memorize when a user visits a specific page of your website.
Step 1:
Copy the following code.
if (window.location.pathname === '/example') {
wisepops('properties', {
ExamplePageVisit: new Date(),
});
}
Step 2:
Replace /example in the code above with the URL you're targeting.
We also recommend you rename the property ("ExamplePageVisit" in my example)
Here's what the code would look like if I were to target our pricing page (URL = https://wisepops.com/pricing/)
if (window.location.pathname === '/pricing') {
wisepops('properties', {
PricingPageVisit: new Date(),
});
}
Code implementation
Paste the code you just prepared right before the closing </script> tag of your Wisepops setup code. (If you're using our Magento or Shopify extension, contact us, we'll help you implement the script.)
Here's an example of what you should end up with:
Display scenario
Now that the script is implemented, we have a new custom property that we can use.
Every time a user visits the page, the custom property's value will be updated to reflect the time of her visit.
To target visitors who have already been on the page, create the following rule (remember to replace "PricingPageVisit" with the name of your own property):
If you want to exclude the visitors who have been on the page, add the following condition:
Target visitors who've been on URLs that contain a keyword
If you want to target all the URLs that contain a keyword, you can use this script instead:
if (window.location.href.indexOf('examp') > -1) {
wisepops('properties', {
ExamplePageVisit: new Date(),
});
}
This script would work for wisepops.com/example or wisepops.com/examples.
Target visitors who've been on URLs A, B or C
You can use the following script to achieve this:
if (['/ExamplePageVisit', '/otherpage1', '/otherpage2'].indexOf(window.location.pathname) > -1) {
wisepops('properties', {
ExamplePageVisit: new Date(),
});
}
Target visitors who've seen a specific URL this many times
You can use the code below to target these users.
if (window.location.pathname === '/example') {
var wisepopsPageVisitCount = localStorage.getItem('wisepops.ExamplePageVisit') || 0;
localStorage.setItem('wisepops.ExamplePageVisit', ++wisepopsPageVisitCount);
wisepops('properties', {
ExamplePageVisit: wisepopsPageVisitCount,
});
}
Then go into your popup Display tab and enter the number of page visits, as shown below:
Any questions? Feel free to contact us via chat.