Profile Script for IP range | Community
Skip to main content
melissae6854041
New Participant
May 6, 2016
Solved

Profile Script for IP range

  • May 6, 2016
  • 13 replies
  • 8562 views

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.
Best answer by ParitMittal

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

13 replies

New Participant
April 19, 2019

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);

muhammeda378996
New Participant
November 6, 2018

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.

New Participant
March 21, 2018

Thanks, but this doesn't work...

New Participant
March 21, 2018

Here is how mine is set up (bluring out IP's)

I create my audience by saying Visitor Profile; user.isInIpRange contains "webRange" where isInIpRange is the Profile Script and webRange is the value that would be returned in the script. 

New Participant
March 21, 2018

I don't get it working in Adobe target standard.

Is it normal that in the available tokens I don't see user.header?

My audience based on this script doesn't work...

New Participant
November 29, 2017

I just had to go through this exercise...see below:

/^(192.236.17.44|192.168.1.1|192.168.5.2)$/.test(strIp);

Separate it by a pipe as an OR statement.

New Participant
September 29, 2017

I've used this in the past for multiple IP addresses:

IP Address Exclusion/Inclusion Script Generator

You can put in ranges or single IPs. Be careful though, if you enter too many, the script breaks with no warning as Target has limits on the length of profile scripts but for some reason it doesn't tell you the limit on save (unless this has changed recently).

s_kala
New Participant
September 28, 2017

Hi Parit,

Can you explain this code. Specially /^(192.236.17.44)$/.test(strIp); part so that I can modify it to enter multiple IP addresses. I am finding it difficult to comprehend this code.

Thanks,

Suchindra Kala

ParitMittal
ParitMittalAccepted solution
New Participant
May 18, 2016

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

snoverd
New Participant
June 30, 2020

Hi Parit, How can you manipulate this scrip to add ranges of IP addresses? 

melissae6854041
New Participant
May 16, 2016

Says that that the syntax is invalid.  Will not publish to adobe delivery network.