I'm fetching Job ID, Subscriber key of a subscriber into a Data Extension who clicks the landing page.

Code in the Email

%%[ SET @Sub = _subscriberkey SET @CloudPageID = 1234]%% 

Code in landing page


set @Subs = AttributeValue('_SubscriberKey')
 set @JobId = AttributeValue('jobID')
 set @memberid = AttributeValue("memberid")
 set @member_busname = AttributeValue('member_busname')

 Set @lookUp = LookupRows('Page Visits','Subscriber Key', @Subs,'jobid', @jobid)
 SET @lookupvalue = LookupRows('BU Details','memberid', @memberid)

IF Rowcount(@lookupvalue) >0 THEN
   SET @BURow = Row(@lookupvalue, 1)
   Set @BUName = Field(@BURow, 'BUName')

 IF RowCount(@lookUp) == 0 THEN 
 InsertData('Page Visits','Subscriber Key', @Subs,'jobid', @jobid,'memberid', @memberid, 'member_busname', @member_busname , 'Event Date', NOW())

I've created one DE called "Landing page" and fetching the LPNAME field and inserting into Page Visits DE. I'm using the below which is not working

SET @lookupvalue = LookupRows('landing page','LPNAME', @LPNAME)

IF Rowcount(@lookupvalue) >0 THEN    SET @LPRow = Row(@lookupvalue, 1)    Set @LPName = Field(@LPRow, 'LPName') ENDIF

Thanks In advance, Kiran

3 Answers 3


I reviewed this with @kiran on a webinar.

He is now storing the Page URL of the CloudPage in a 'Landing Page Details' DE with the page name.

You can use this URL value to lookup the page name from the DE. In order to do this, you need to strip the query string parameters from the PAGEURL which I have done by locating the ? position using AMPscript IndexOf function and then use the Substring function to retrieve the URL, which can then be used in a lookup.

The following code will work.


set @Subs = AttributeValue('_SubscriberKey')
set @JobId = AttributeValue('jobID')
set @memberid = AttributeValue('memberid')
set @pageURL = RequestParameter('PAGEURL')

set @queryStringPosition = Subtract(IndexOf(@pageURL,'?'),1)

set @baseURL = Substring(@pageURL, 1, @queryStringPosition)

set @cpName = Lookup('Landing Page Details', 'CPNAME', 'pageURL', @baseURL)

SET @buName = Lookup('BU Details', 'BUName', 'memberid', @memberid)

set @pageVisits = LookupRows('Page Visits','Subscriber Key', @subs, 'pageURL', @pageURL)

if RowCount(@pageVisits)==0 then
   InsertData('Page Visits',
              'Subscriber Key', @Subs,
              'jobid', @jobid,
              'memberid', @memberid,
              'BUName', @BUName,
              'pageURL', @pageURL,
              'CPNAME', @CPNAME,
              'Event Date', NOW()
  • Hi @Eliot, Is there a way to avoid duplicates? If I click the same email twice it is tracking two times. I want to track it once only.
    – kiran
    Mar 23, 2020 at 9:12
  • What do you mean by duplicates? Do you mean that you only want to store unique page visits? If so, do you want to update the existing record with the last page visit? Or do you only want to track the first page visit? Mar 23, 2020 at 17:31
  • I want to track only the first page visit
    – kiran
    Mar 24, 2020 at 3:50
  • No problem, I've updated my answer Mar 25, 2020 at 1:25

This is unfortunately not possible, as there is no personalization string holding the value of the cloud page name. My best suggestion will be either pass it in CloudPagesURL, from an ampscript variable - or to use link alias instead:

<a href="https://www.salesforce.com" alias="Make This Unique">SFMC</a>

You will be able to pass it on in your Ampscript call, like this:

InsertData('Page Visits','Subscriber Key', @Subs,'jobid', @jobid,'memberid', @memberid, 'member_busname', @member_busname , 'linkname', linkname, 'Event Date', NOW())

Be aware, that you don't need to pass these standard personalisation strings as Attribute Values - they are immediately available as linkname above, when you use CloudPagesURL


You can't get the actual landing page name, but you can retrieve the page URL along with any URL parameters using the personalization string PAGEURL. For example, set the following variable on your landing page:

set @pageURL = RequestParameter("PAGEURL")
  • Thanks, it is working. I'm planning to bring the Landing page name from a DE, Set lookUp = LookupRows('Page Visits','Subscriber Key', Subs,'jobid', jobid) SET lookupvalue = LookupRows('BU Details','memberid', memberid) SET lookupvalue1 = LookupRows('Landing Page Details','CPID',CPID) IF Rowcount(lookupvalue) >0 THEN SET BURow = Row(lookupvalue, 1)Set @BUName = Field(BURow, 'BUName') ENDIF IF Rowcount(lookupvalue1) >0 THEN SET CPRow = Row(lookupvalue1, 1) Set CPNAME = Field(CPRow, 'CPNAME') Already I'm getting one DE (BU Details), How to bring landing page DE details?
    – kiran
    Mar 18, 2020 at 9:21
  • 1
    You are only retrieving the first row with the Row function. You need to use a process loop to loop through the rowset. Mar 18, 2020 at 9:30
  • For fetching the data from 2 DE's can we use for loop?
    – kiran
    Mar 18, 2020 at 9:45
  • If you are only getting 2 rows, then you can just get each row separately from the rowset using the Row function. e.g. set @variableA = Field(Row(@rowset, 1), 'FieldName') set @variableB = Field(Row(@rowset, 2), 'FieldName'). If you need additional examples, I would encourage you to update your original question, or post a new question. Mar 18, 2020 at 10:39
  • I will try with using the variables, I've updated my question. Thanks,
    – kiran
    Mar 18, 2020 at 11:00

You must log in to answer this question.

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