18 Replies Latest reply on Mar 3, 2017 10:31 AM by Sanford Whiteman

    Track File Links?

    Lisa Heay

      We have our resource files (PDFs - guides, ebooks, etc.) loaded in Marketo.  We share these links via landing pages, Marketo emails, etc, but often times we will also share a direct link to a file through a social post (tweet, facebook, LinkedIn, etc.) or personal/Outlook (non-Marketo) email.  We want to be able to track link clicks when someone engages through one of those outside means.  I'd also like to be able to trigger a Marketo campaign with a follow up cadence when a click occurs.  Is this possible?  This may be a dumb question - forgive me, it's Friday.

        • Re: Track File Links?
          Sanford Whiteman

          It's not a dumb question.

           

          You can't track the actual click/tap event on a site that isn't running Munchkin. You can, however, track the subsequent pageview that results from visiting a Munchkin-tracked redirector page, before that page redirects to the actual downloadable asset.

           

          In fact this is the way everyone should share assets. Sending direct links to assets, even from Marketo-generated emails, is bad for tracking.

          2 of 2 people found this helpful
            • Re: Track File Links?
              Lisa Heay

              Interesting - ok.  How do I implement a redirector page so that I can track the pageview?

                • Re: Track File Links?
                  Lisa Heay

                  Most importantly, I'd like to be able to trigger a smart campaign when someone clicks one of these asset links.  Any guidance you could provide would be much appreciated. Thank you!

                    • Re: Track File Links?
                      Sanford Whiteman

                      Yep, triggering an SC works fine. Your goal is to capture the pageview, and what you do with it is up to you.

                       

                      I'm on my phone but a little later I'll give you a few lines of lightweight/primitive code to create a flexible redirector page.

                        • Re: Track File Links?
                          Lisa Heay

                          Perfect - thank you!

                            • Re: Track File Links?
                              Sanford Whiteman

                              OK, I'm going to give you the easiest, dirt-simple, this-isn't-the-way-I-would-do-it-but-here-I-am-showing-it-to-you-anyway method.

                               

                              Add this to the document <head> of your redirector page (which should be otherwise empty). Turn off Munchkin at the page level as you're loading it manually.

                               

                              <script type="text/javascript">
                                document.write(unescape("%3Cscript src='//munchkin.marketo.net/munchkin-beta.js' type='text/javascript'%3E%3C/script%3E"));
                              </script>
                              <script>
                                Munchkin.init('111-222-333'); // your Munchkin ID and options, obviously!
                              </script>
                              <script>
                                (function(redirectTarget){
                                  var allowedOrigins = [
                                       'http://pages.example.com',
                                       'http://www.example.com',
                                       'http://example.com'
                                      ], // which domains are allowed for redirection
                                      redirectMs = 3500, // how long before redirecting  
                                      progressMs = 500,  // how long between updates of the "progress meter"
                                      progressChar = '&bull;', // progress character (HTML bullet)
                                      errNoAsset = 'Asset URL not found.', // message when no asset in hash
                                      errInvalidAsset = 'Asset URL not allowed.', // when asset not our domain
                                      progress = setInterval(function(){
                                        if (redirectTarget) {
                                          document.body.insertAdjacentHTML('beforeend',progressChar);
                                        } else {
                                          clearInterval(progress), clearTimeout(redirect);          
                                          document.body.insertAdjacentHTML('beforeend',errNoAsset);          
                                        }
                                      }, progressMs),
                                      redirect = setTimeout(function(){         
                                          var redirectLoc = document.createElement('a');
                                          redirectLoc.href = redirectTarget;
                                          clearInterval(progress);
                                          if (allowedOrigins.indexOf(redirectLoc.origin) != -1) {            
                                            document.location.href = redirectTarget;
                                          } else {
                                            document.body.insertAdjacentHTML('beforeend',errInvalidAsset);                   
                                          }
                                      }, redirectMs);
                                  })(document.location.hash.substring(1));
                              </script>
                              

                               

                              Then, to link to your assets, append your asset URL after the hash (#) in the redirector page: http://pages.example.com/redirector.html#http://example.com/redirected.pdf

                               

                              You can then trigger on the asset downloads as pageviews:

                               

                              2017-01-27 23_37_04-Marketo _ Redirect detect (Smart List) • Marketing Activities.png

                               

                              The reason I don't do it exactly this way on my own production sites is that it adds a mandatory minimum delay before redirecting in expectation/hope that Munchkin will load + log completely in that period. The delay above is 3.5 seconds (3500ms) which is okay for, let's say, 99.99% of cases -- but not all. Instead we have a custom Munchkin library (we call it "Munchkin Enhanced") that can ensure the delay is just long enough for the hit to be logged, but no longer.  Anyway, this should fit your needs for the most part.

                              2 of 2 people found this helpful