Skip to main content
melissae6854041
Level 2
May 6, 2016 1:18 PM UTC
Solved

Profile Script for IP range

Hello, 

We are creating an experience where our success metric is time on site.  We have content authors who spend a lot of time on the site reviewing articles and making edits.  We would like to block our content authors from being included into the campaign so the results are not screwed.  My thought was to create a profile script to determine IP address.  We would then use this script to create an audience that targets everyone but those ranges  Could someone please comment on how to set this up?  

Thanks for any assistance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
ParitMittal
ParitMittalAccepted solution
Level 10
May 18, 2016 9:10 AM UTC

Hi ,

We have to change the syntax a bit. Please use the following code :

var strIp= user.header('x-cluster-client-ip');
 
var res = /^(192.236.17.44)$/.test(strIp);
 
if (res)
{
return "Invalid IP";
}
else
{
return "Valid IP";
}

Please let us know if you have any more queries.

Thanks & Regards

Parit Mittal

14 replies

Mar 21, 2018 4:34 PM UTC

Thanks, but this doesn't work...

Translate
muhammeda378996
Nov 6, 2018 7:10 AM UTC

Thanks, everyone for this great info! How do I mention multiple ranges of IPs in the following code?

var res = /^(192.236.17.44)$/.test(strIp);

Can anyone please explain by mentioning 2-3 dummy IP range.

Translate
Level 4
Apr 19, 2019 4:30 AM UTC

Multiple full IPs would be
var res = /^(192.236.17.44)$|^(192.236.17.45)$|
^(192.236.17.46)$/.test(strIp);

If you just want to match "starts with" you can drop the "$" at the end

var res = /^(192.236)|^(192.237)|^(192.238)$/.test(strIp);

Translate