0

How to retrieve the Subscriber Id from a landing page given that we know what the Subscriber Key is?

I tried placing the following ampscript and javascript in a landing page and don't see the subscriber id listed.

AMPSCRIPT:

%%[

SET @subkey = requestParameter("Email Address")

SET @rr2 = CreateObject("RetrieveRequest")
SetObjectProperty(@rr2,"ObjectType","Subscriber")
AddObjectArrayItem(@rr2, "Properties", "ID")
AddObjectArrayItem(@rr2, "Properties", "EmailTypePreference")
AddObjectArrayItem(@rr2, "Properties", "EmailAddress")
AddObjectArrayItem(@rr2, "Properties", "SubscriberKey")
AddObjectArrayItem(@rr2, "Properties", "Status") 


SET @sfp2 = CreateObject("SimpleFilterPart")

SetObjectProperty(@sfp2,"Property","SubscriberKey")
SetObjectProperty(@sfp2,"SimpleOperator","equals")
AddObjectArrayItem(@sfp2,"Value",@SubKey)

SetObjectProperty(@rr2,"Filter",@sfp2)
SET @atts = InvokeRetrieve(@rr2,@status)

IF RowCount(@atts) > 0 THEN

                SET @subAtts = Field(Row(@atts,1),"Attributes")

                FOR @c = RowCount(@subAtts) DOWNTO 1 DO 
                                SET @att = Row(@subAtts,@c)
                                SET @att_name = Field(@att,'Name')
                                SET @att_val = Field(@att,'Value')

]%%
Att: %%=v(@att_name )=%%   %%=v(@att_val)=%%<br/>
%%[

                NEXT @c
ENDIF
]%%

JS:

<script  runat="server">

    Platform.Load("core","1");

    try {
            var results_DI = Subscriber.Retrieve({Property:"SubscriberKey",SimpleOperator:"equals",Value:"[email protected]"});
                var resultsLength_DI = results_DI.length;
                Write("<br/>" + resultsLength_DI + "<br/>"); 

var subObj = Subscriber.Init("[email protected]");
var attributes = subObj.Attributes.Retrieve();
Write("<br/>" + Stringify(attributes) + "<br/>"); 
var listArray = subObj.Lists.Retrieve();
Write("<br/>" + Stringify(listArray)  + "<br/>"); 


    } catch (ex) {
        Write("An error has occurred: " + Stringify(ex));
        Variable.SetValue("@Result", Stringify(ex));  //sets above ampscript variable
    }
</script>
1
  • 1
    Can we see some code to help narrow down the question? Aug 8, 2014 at 9:06

1 Answer 1

2

Use the personalization string %%subscriberid%% If the subscriber is coming from an email, and you are using MIRCROSITE BASE URL, it will populate.

4
  • The landing page has subscriber key passed to it only.
    – user10250
    Aug 7, 2014 at 22:17
  • If the subscribers are arriving from an email, then what @edu8rdo suggested is the way to go. Aug 11, 2014 at 17:45
  • The susbscribers are not arriving from an email.
    – user10250
    Aug 11, 2014 at 22:50
  • If not from an email, you're going to need to use the microsite's full URL with appended parameters. Oct 27, 2014 at 22:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .