So you have some PDF files on your site, and you would like Site Monitor to track visitors going to your PDF's. There's just one small problem....PDF's are not an extension of your website (i.e a page or subdomain). They are dedicated URL's for documents that you/someone has published. However, this IS a way to track that someone has visited/downloaded a PDF. Here's how:
You need need to create an html redirect that is trackable before the visitor actually lands onto the PDF. The HTML file should be the page where the tracking code is found and possibly want to let users know they're being redirected to a download side. You will want to edit the file name here (only the file name, not the dir to it)Now the message can be changed to something like "Redirecting you, please wait" or something to the affect so that the lead will not click out of the URL and stay put.
In this example, upon redirect, the lead will see a page that says "Hello World" before being redirected to the PDF.
You will also need to insert the Site Monitor Tracking Code (notice that the code isn't input in this example, but we show you where in the script to place it).
Things to know:
- The getUrlParameter function gets the query string from an URL. Then it's the actual redirection function
- On line 40, you want to enter the full path to your download (read + write) server-side script, as detailed in the following paragraphs
Lastly, before you can begin tracking PDF's, there is an additional task for the web programmers that is not particularly the subject of this article; that is, to read and print the contents of the actual file and prompt the download dialog box on a browser. Create a PHP file (in this example) and add this code. Let's name this file download.php. Remember to change the line 40 in the JS/HTML page above and enter a path like 'download.php?f=dir/and/file/here'
Note: The $dir variable needs to be edited to correctly contain the path to your file directory.
Important Note: This is just a simple example of how you would do things in PHP. There are serious security concerns one needs to address in order to allow access to a file on their web server. This is outside of the scope of this article
Another thing to consider is you can write this code in any language you're familiar with, we just used PHP for this example. C#, Java, Python could also work, to name a few.
Well, now that you can track PDF downloads, wouldn't it be awesome to score, or even put Known Visitors into an automated workflow?
It's very simple, all you need to make sure is that you're putting the FULL URL in either the action wizard
The words in bold is what you'll replace with your own URL and PDF.
Here's how it should be setup in Scorecards:
Here's how to setup an Automated action based on Web Activity using the Same URL:
Unfortunately, cannot show the entire URL, but it's there! Make sure not to miss any forward slashes (/) or forget the Http/s or anything that would cause the URL not to be read.
And that's how you can leverage coding to track PDF downloads from your site!