Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Profile Script for IP range

Avatar

Avatar
Validate 1
Level 1
melissae6854041
Level 1

Likes

3 likes

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
melissae6854041
Level 1

Likes

3 likes

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
melissae6854041
Level 1

06-05-2016

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

90 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

90 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile
ParitMittal
Level 10

18-05-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

Answers (12)

Answers (12)

Avatar

Avatar
Validate 1
Level 5
nickh86417692
Level 5

Likes

68 likes

Total Posts

66 posts

Correct Reply

26 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 5
nickh86417692
Level 5

Likes

68 likes

Total Posts

66 posts

Correct Reply

26 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
nickh86417692
Level 5

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

Avatar

Avatar
Level 1
muhammeda378996
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
muhammeda378996
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
muhammeda378996
Level 1

05-11-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.

Avatar

Avatar
Level 1
karinec21501309
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
karinec21501309
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile
karinec21501309
Level 1

21-03-2018

audience-internal-ag.JPGThanks, but this doesn't work...

Avatar

Avatar
Boost 1
Level 1
david_parker3
Level 1

Likes

2 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
david_parker3
Level 1

Likes

2 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
david_parker3
Level 1

21-03-2018

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

screenshot.jpg

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. 

Avatar

Avatar
Level 1
karinec21501309
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
karinec21501309
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile
karinec21501309
Level 1

21-03-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?

user-header.jpg

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

Avatar

Avatar
Boost 1
Level 1
david_parker3
Level 1

Likes

2 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
david_parker3
Level 1

Likes

2 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
david_parker3
Level 1

29-11-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.

Avatar

Avatar
Level 1
laurenr36581018
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
laurenr36581018
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile
laurenr36581018
Level 1

29-09-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).

Avatar

Avatar
Validate 1
Level 2
s_kala
Level 2

Likes

11 likes

Total Posts

12 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
s_kala
Level 2

Likes

11 likes

Total Posts

12 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
s_kala
Level 2

28-09-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

Avatar

Avatar
Validate 1
Level 1
melissae6854041
Level 1

Likes

3 likes

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
melissae6854041
Level 1

Likes

3 likes

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
melissae6854041
Level 1

16-05-2016

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

Avatar

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

90 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

90 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile
ParitMittal
Level 10

15-05-2016

Hi,

If you already know the Ip Address that need to be blocked then , You just have to update the profile script like this :

  1. var strIp= user.header('x-cluster-client-ip');
  2.  
  3. var res = "192.236.17.44";
  4.  
  5. if (res!=strlp)
  6. {
  7. return "Valid IP";
  8. }
  9. else
  10. {
  11. return "Invalid IP";
  12. }

and create an Audience like below :

Thanks & Regards

Parit Mittal

Avatar

Avatar
Validate 1
Level 1
melissae6854041
Level 1

Likes

3 likes

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 1
melissae6854041
Level 1

Likes

3 likes

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
melissae6854041
Level 1

13-05-2016

So in Target Standard, what would be the next step for blocking the IP address of: 192.236.17.44? 

I know I need to create an audience using this profile script but in the dropdown I am not sure what you would choose.  Equals, Contains, Parameter is preset... etc.

Avatar

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

90 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 10
Level 10
ParitMittal
Level 10

Likes

90 likes

Total Posts

817 posts

Correct Reply

349 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile
ParitMittal
Level 10

11-05-2016

Hi , 

You can access the IP address of visitor using user.header('x-cluster-client-ip’) in a  profile script. Please see the below profile script code: 

  1. var strIp= user.header('x-cluster-client-ip');
  2.  
  3. var res = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/.test(strIp);
  4.  
  5. if (res)
  6. {
  7. return "Valid IP";
  8. }
  9. else
  10. {
  11. return "Invalid IP";
  12. }

The above code checks whether an IP address is a valid IP address or not on the basis of Regular Expression defined in the script and then returns the Valid or Invalid Ip . In your case , you can create a Regular Expression on the basis of your requirements and then check if the visitor ip address is a valid one or not. 

After All the Set up , You can create an Audience named as "Valid Audience" and add "Visitor Profile" as a rule and then choose the  above created profile script name as the refinement.

Please let us know in case of any more questions or queries.

Thanks & Regards

Parit Mittal