Call 1-888-670-1652

 Spire CoreDB Connect Error (2002) Connection timed out

How To Track Downloaded Files On A Form

Should you wish to be informed whenever users download a particular file on your website by having this information added to their completed forms, you can make use of the sys:xform-user-update tag.

Within the CMS administration, simply create a new page for the downloadable file with a URL (such as "/download-pdf") that will help to make clear the page's purpose and distinguish the file from others on your site.

Once created, open the page's "Content" tab, and enter the tag into the "Source" editor window.

In entering the tag, you should make use of the following attributes, which will help to determine how the download information will be reported in users' forms:

  • form: This attribute indicates the ID number of the form that you would like the download information to be added to
  • field: This attribute indicates the ID number of the field within the form that you would like the information to be displayed in
  • value: This attribute specifies the value or string of text that will be displayed in the selected field when a user has downloaded the file
  • increment: This attribute specifies a particular value to increase or decrease the selected field's current value by whenever a user downloads the file

The attributes can be added to the tag in any order you like, with the one stipulation being that you cannot use both the value and increment attributes in a single tag, as they are mutually exclusive.

In the end, when entered into the new page's "Source" editor window, the tag should look something like this:

<sys:xform-user-update form="F3" field="D30" increment="+1" />

In order to specify exactly what file will be served to users when they select to download it from this page, you should then enter a sys:serve tag on the next line of the page's "Source" editor window in the following manner:

<sys:serve file="./data/documents/manual.pdf" mime="application/pdf" download="yes" />

!NEED SCREENSHOT SHOWING HOW TO ENTER TAG

The attributes within the sys:serve tag should be completed as follows:

  • file: This required attribute should be completed with the complete filepath of the desired file relative to the document root ("./data/documents/manual.pdf" in the example above)
  • mime: This required attribute should specify the file's MIME type information in order to tell the operating system how to open the file ("application/pdf" in the example above)
  • download: If used with the value "yes" (as in the example above), this optional attribute will cause a "Save as..." pop-up window to appear when users select to download the file (if excluded, the file will be displayed within the browser window, rather than being treated as an external attachment)

The end result should look something like this:

!NEED SCREENSHOT OF FORM SHOWING THAT USER DOWNLOADED FILE