2
votes

how do I track a pdf download with sitecore page events? I have code which tracks the event from back end but how do you determine whether the link is external, internal or a media link? And how can you determine if media link is pdf?

public void RegisterDownload(string downloadedResourceText, ID itemId)
        {
            if (downloadedResourceText != null)
            {
                if (TrackerEnabled())
                {
                    var page = CurrentPage();

                    page.Register(new PageEventData("Download", _downloadPageEventGuid) { ItemId = itemId.ToGuid(), Data = downloadedResourceText, DataKey = downloadedResourceText, Text = "Resource Downloaded" });
                }
            }
        }
1
Do you want to track it with code or with OOTB Sitecore? If its Sitecore, then just set the event in the "Tracking" field for the PDF item, in the media library. Its the "Attributes" link on the "Tracking" field. - Chris Auer
If this can be done using sitecore that would be great else yeah I want to track it using code. Can you please specify where is this tracking field in any pdf uploaded to media library? - user1994316
See my notes below. I figured some images would go a long way. Any page or media item can have events or goals assigned to them in sitecore via the tracking field. - Chris Auer
If this solved your issue, can you please mark it as resolved. - Chris Auer

1 Answers

7
votes

If you want to do it with Sitecore, just set the event in the Tracking field for the PDF in the media library.

enter image description here

Then it shows up in the experience profile or you can trigger a engagement plan, etc...

enter image description here

If you are looking to do it programmatically, you have to create the details of the event. You just pass in a string of "User did X" to the page event code you have posted. The itemID is the page they were on when they did it. If it was a brochure, you would have "downloaded the brochure for product XYZ".

Some good details of the properties of the page event call can be found here: https://doc.sitecore.net/sitecore_experience_platform/82/digital_marketing/marketing_operations/events/register_a_page_event_programmatically