I am putting your question here as the answer is more Dev oriented.
I am trying to create a link within an email – that when clicked adds
the contact’s email address to a data extension (along with some other
predefined fields) such as the link url and the datestamp etc. I am
trying to achieve this through creating an API call to add a row to a
data extension to be called from within the email (through the href
link). Does that make sense? Is there an easier way or a built in
functionality to do this in MC?
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
As I was saying on the Marketing Cloud group, an easy way to achieve this is to have landing page between your link and your destination page. The page is hosted on Cloudpages and can perform different AMPscript operation to insert values in a Data Extension. Then have a auto redirect call to the desired webpage. This a custom solution, not an OOB feature of Cloudpage. Someone with AMPscript and HTML knowledge is required.
If you want to try it yourself here is an example:
In your Email
%%[ SET @destinationURL = "myFinalURL.com" SET @email = [email address] SET @datestamp = Now() SET @attribute1 = [attribute 1] SET @attribute2 = [attribute 2] Set @url = Concat('http://www.example.com?destinationURL=',@destinationURL,'&email=',@email,'&datestamp=',@datestamp,'&attribute1=',@attribute1,'&attribute2=',@attribute2) ]%% <a href = '%%=RedirectTo(@url)=%%'>Click Here</a>
<a href="%%=RedirectTo(CloudPagesURL(533, 'destinationURL', @destinationURL,'email', @email, 'datestamp', @datestamp, 'attribute1', @attribute1, 'attribute2', @attribute2))=%%" rel="nofollow noreferrer noopener">Click Here</a>
Note: Some attribute like subscriber key or email should be passed automatically. The 533 should be replaced by your Cloudpages ID.
In your Cloudpage
%%[ SET @destinationURL = RequestParameter("destinationURL") SET @email = RequestParameter("email") SET @datestamp = RequestParameter("datestamp") SET @attribute1 = RequestParameter("attribute1") SET @attribute2 = RequestParameter("attribute2") /* do your Data Extension operation here like InsertData */ ]%% <meta http-equiv="refresh" content="0;URL=%%=v(@destinationURL)=%%">
Info on InsertData function
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0