1. Home
  2. Modules
  3. Templated Experiences
  4. Code Snippets for Hiding Download and Print Options from Unknown Visitors
  1. Home
  2. Modules
  3. Standard Experiences
  4. Code Snippets for Hiding Download and Print Options from Unknown Visitors

Code Snippets for Hiding Download and Print Options from Unknown Visitors

When visitors view PDF assets within PathFactory Content Tracks, our native PDF Viewer provides the Download and Print options. The following code can be leveraged to prevent unknown visitors from downloading PDFs until they are known in PathFactory. This will prevent visitors from accessing the PDFs without having a known email address associated with their PathFactory engagement data.

To see more examples of code snippets, read Frequently Used External Code Snippets to Personalize Your PathFactory Experiences.

See This Code In Action

Below is an example of a form for an Unknown Visitor.

Below is the Experience appearance for a Known Visitor (no form pops up).

Where to place the script?

This script can be added through your External Code library and you can find a step by step guide on how to do so in our article Using External Code. The location can be set to either of the ‘Head Tag’ or either of the ‘Body Tag’ options. This can be applied globally to any PathFactory instance.

Code Snippet

<style id=”pdfDlHide” type=”text/css”>

  #toolbarViewerRight #download,

  #toolbarViewerRight #print {

    display: none!important;

  }

</style>

<script>

    handleJukeboxDispatchedEvents_show_dl = function (event) { 

        switch (event.detail.eventName) { 

            case “load_show”: 

                if (“{{visitor.email}}” != “”) {

                    document.querySelector(‘#pdfDlHide’).type = ‘text/plain’;

                } 

            break; 

        } 

    }

    window.addEventListener(“pf_event”, this.handleJukeboxDispatchedEvents_show_dl, false);

</script>

Updated on July 27, 2023

Was this article helpful?

Need Support?
Can't find the answer you're looking for? Don't worry we're here to help!
CONTACT SUPPORT