We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20046
    • 14 Posts
    Hi,

    my client wanted me to add a download tracking function on their website. They have a number of PDF files that users are only allowed to download after entering name, company name, email etc. information to a form, after the form is filled in all these files becomes available to be downloaded. My client wants to know who is downloading their brochures and use this information for marketing purposes, therefore the information should be saved into database/textfile or generate email. It would be good to save session of "logged in" user so that if he/she decided to go back to download more files later, it could be done without filling in the form again. I’m a web designer (not much experience with PHP), so i’m hoping some more experienced developer could advise me.

    Is there a plug-in or any other MODX feature that could help me to do something like this? Or is it better to start coding from scratch? I’m sure this is very simple to code for most of you guys...

    Thanks
      • 25519
      • 265 Posts
      Hi

      Off the cuff, you could create a members area, pretty standard stuff with modx, and serve the pdf’s to the logged in members. You’ll have all the data you need about members from this and you can email/market them etc with any number of snippets, e.g. Easy Newsletter.

      Then you could set up some goal tracking with, say, Google Analytics, to track the pdf downloads. You can write, or commission, some custom javascript to funnel these download stats - maybe that’s even ’off the shelf’ with GA anyway, but I don’t know. The squeeze here would be pinpointing who downloaded what and when and balancing this against who was logged in - GA v MODx - but that’s where IP’s come in handy.

      Sure, that’s not all modx ’in-house’, but both methods are readily available to you without tooo much fussing, depending on how in depth you want to go.

      Like i said, this is off the cuff wink
        • 20046
        • 14 Posts
        Thanks for the tips redplanet,

        i used Login snippet to create a register form and it works just fine, new users are added to correct user group. My client however wants a form that only requires full name, company, email and phone number, the problem is that i can’t get it working with these fields, without submitting username and password which are obviously mandatory fields for MODX user registration?

        In which table are custom fields added in the database? I just added company as custom field (http://rtfm.modx.com/display/ADDON/Login.Using+Custom+Fields).

        I could add two hidden fields for usename and password, and give them default values. However, it seems like duplicate username values are not allowed in the database, therefore new user overwrite existing one.
          • 25519
          • 265 Posts
          a form that only requires full name, company, email and phone number, the problem is that i can’t get it working with these fields, without submitting username and password which are obviously mandatory fields for MODX user registration?
          I’m a little unsure what you mean there - you can create a custom template for the form and pass that through one of the snippet parameters, so you can use whatever form you like.

          But you will certainly need the user/pass in order to register. Or maybe i’m missing something obvious here - it’s been a long day tongue
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            I use a plugin to add username and password to the POST using the email address for the username and anything that tickles my fancy at the moment for the password; a favorite is to use time(). The password can be changed if it’s ever wanted for anything.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 32316
              • 387 Posts
              A couple of ’off the cuff’ ideas:

              If you don’t require them to be logged in to view the pdfs (or whatever) just use a form that requires the person to enter the information and then forwards them to the pdf when they hit the enter button which posts their info to your database.

              Or you could make their name the username and the company name the password (not very secure but it seems like that is not your priority) the viewer would see a form with name and company - modx would get a username and a password and then you could track things using the various built in ’stuff’ that goes along with registered users.
                • 2453
                • 26 Posts
                You could use PHP sessions to store user info entered from the form, then take the user to a page with all your files listed, but not linked directly. Instead have them link to a specific hidden resource, not the files themselves. Have these links open in a new window.

                Then, on these individual resources have a snippet that takes their info from the session in addition to the name of the pdf they’re downloading from that page, and emails it to someone. That resource could be opened as a pop-up window sized small for example, with the text "Please wait while we fetch your download..." or something. On that resource the actual link would reside, or better would be sent to the user without them having to click on a link. Does that make any sense?

                The downside would be if the user downloads 3 of your files, you’d get 3 emails sent out.

                I’m no PHP wiz by any means, but sometimes I like to try smiley. There is probably a better way to do this. I’m curious to hear of your solution.