5 Replies Latest reply on Dec 5, 2018 6:14 AM by Luke Wotton

    Can I get user based segments with API call rtp("get","visitor",)?

    s watanabe

      Hi,

       

       

      I'm trying to get visitor segments and show contents for segments not by RTP template.

       

      I've got my own segments with API call like rtp('get','visitor',function(e){console.log(e.results)})

      But it seems to be session based, After I reopen browser and call API, e.results returns nothing.

       

      Did I misunderstand something? Is there any way to get cookie or user based segments with API call?

       

       

      tested on

      windows 10 64bit

      Google Chrome 69.0.3497.100

        • Re: Can I get user based segments with API call rtp("get","visitor",)?
          Yanir Calisar

          Hey

          This is the expected behavior since a segment matches visitors only once per session (session lasts 30 minutes).

          You'd have 2 option to achieve what you described:

          1. When a visitor matches one of your relevant segments - store this in a new cookie you create and use it to personalize the pages for as long as you want.

          2. Use the RTP's campaign editor as your code editor and "inject" the code of your custom campaign to the website when a visitor matches the segment.

          You can also set the RTP campaign to be sticky and then it will show up during the whole session.

            • Re: Can I get user based segments with API call rtp("get","visitor",)?
              s watanabe

              Hey

              This is the expected behavior since a segment matches visitors only once per session (session lasts 30 minutes).

              Thanks Yanir,

              I didn't know that, and understood.

               

              1. When a visitor matches one of your relevant segments - store this in a new cookie you create and use it to personalize the pages for as long as you want.

              2. Use the RTP's campaign editor as your code editor and "inject" the code of your custom campaign to the website when a visitor matches the segment.

              I think Option2 is easy for development. and I tried that.

               

              I set DOM to my test page html.

              <div id="inject_test"></div>

               

              And  create campaign and INJECT my code to rtp zone html editor like    var my_campaign="inject_test";

              inject_test.JPG

               

              It worked well, I can get my_campaign variant in javascript.

              But After I reopen my browser, code injection doesn't work and my_campaign variant returns undefined.

              I don't understand why does it happen. any Ideas for this?