I think I would use the same approach as you describe above. On the link for the PDF I would probably add a data-mediaid attribute, which can be used to hold the reference for the media id and then hook into the link when it's clicked to for instance make an ajax call to a service, which can accept the id and store it in a database.
Are you going to save the information in a custom database table or what is the intention? Or could it be good enough for you to use Google analytics for capturing this? What is your scenario for needing to store this information? :)
No need to be sorry - We've all been there and I could just have explained what I meant in more detail :)
I'm actually "just" thinking of a standard data-* attribute in HTML where you can store the media id on your download link like
<a href="linktomedia" data-media="7829">Download my PDF</a>
Then you can capture the click event and update the database using an ajax call for instance - Does that make sense? :) This is just meant as a rough sketch to give you some inspiration about how you can approach it.
API Call
Hi,
I am trying to capture a media ID, once a member clicks on a PDF download link, and store this information in a database.
Is this at all possible??
using Umbraco 7.2
My approach was to have a jquery or something onclick function on my view which triggers a API method which stores the media ID??
Is this a correct approach or is there a better way to this
I cannot find any sort of information on someone doing this before so any help is appreciated
Thanks
Nav
Hi Naveed
I think I would use the same approach as you describe above. On the link for the PDF I would probably add a data-mediaid attribute, which can be used to hold the reference for the media id and then hook into the link when it's clicked to for instance make an ajax call to a service, which can accept the id and store it in a database.
Are you going to save the information in a custom database table or what is the intention? Or could it be good enough for you to use Google analytics for capturing this? What is your scenario for needing to store this information? :)
/Jan
Hi Jan,
I would be using a custom database table.
Sorry do you know how I would add a data-media id attribute?
Fairly new to umbraco so still finding my way
Thanks
Nav
Hi Naveed
No need to be sorry - We've all been there and I could just have explained what I meant in more detail :)
I'm actually "just" thinking of a standard data-* attribute in HTML where you can store the media id on your download link like
Then you can capture the click event and update the database using an ajax call for instance - Does that make sense? :) This is just meant as a rough sketch to give you some inspiration about how you can approach it.
Cheers, Jan
is working on a reply...