5 Replies Latest reply on May 18, 2016 2:10 AM by ParitMittal

    Profile Script for IP range

    melissae68540411

      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.

        • 1. Re: Profile Script for IP range
          ParitMittal Level 5

          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

          • 2. Re: Profile Script for IP range
            melissae68540411 Level 1

            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.

            • 3. Re: Profile Script for IP range
              ParitMittal Level 5

              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

              • 4. Re: Profile Script for IP range
                melissae68540411 Level 1

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

                • 5. Re: Profile Script for IP range
                  ParitMittal Level 5

                  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