The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. Track PDF files downloaded from my site

    Track PDF files downloaded from my site

    Technical SEO Issues
    15 7 1.7k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • seoug_2005
      seoug_2005 last edited by

      I came across this code for tracking PDF files

      [1. map.pdf  ( name of PDF file )  and files is the folder name. Am i right ?

      2. What shall i be able to track using the code given above ?

      a ) No. of clicks on links or  how many persons downloaded the PDF files ?

      3. Where in Google this report will be visible ?

      Thanks a lot.](http://www.example.com/files/map.pdf)

      1 Reply Last reply Reply Quote 0
      • Nightwing
        Nightwing last edited by

        HI Aful,

        Your event tracking anatomy does not look righ to me. Go here to see how to structure it correctly:
        http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html#Anatomy

        Reagrding where the data should render in Google Anlytics go to Content sub category events ,

        Good luck!

        mad2k 1 Reply Last reply Reply Quote 0
        • nvs.nim
          nvs.nim last edited by

           Using this code will track all the files you offer to download:    
          /**
          	 * Measuring GA Files
          	 */	 
          	var extensions = ['pdf','doc','docx','xls','csv','jpg','gif',
          'mp3','swf','txt','ppt','zip','gz','dmg','xml'];
          	var download_ga_folder = '/downloads/';
          	$('a').each(function(){
          		var _self = $(this);
          		var u = $(this).attr('href');
          
          		if(typeof(u) != 'undefined'){
          			if(u.indexOf("?")!=-1){
          				uext = u.substring(0, u.lastIndexOf("?"));
          			}else{
          				uext = u;
          			};
          
          			var ext = uext.split('.')[uext.split('.').length - 1];
          
          			//check extensions
          			for(i = 0; i < extensions.length; i++){
          				if(ext == extensions[i]){
          					_self.click(function(){
          						pageTracker._trackPageview(download_ga_folder + 
                                                          _self.attr('href'));
          						return false;
          					});
          					break;
          				};
          			};
          		};
          	});
          
          1 Reply Last reply Reply Quote 0
          • mad2k
            mad2k last edited by

            Hi,

            I think that it's better to use event tracking than virtual page-view tracking.

            Syntax and parameters explanation

            _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)'```
            []);">Download](#)

            
            
            
            where: 
            
            -category (required) -  e.g. Maps  (The name you supply for the group of objects you want to track.)
            
             - action (required) -  e.g. Download (A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.)
            
            - label (optional)  - e.g. EuropeMap or filename map.pdf  (An optional string to provide additional dimensions to the event data.)
            
            - value (optional) -  An integer that you can use to provide numerical data about the user event.  It is very complicated to quick explanation and usage, you should read full article and additions like: Implicit Count. 
            
            - non-interaction (optional) - set it for "true" (A boolean that when set to `true`, indicates that the event hit will not be used in bounce-rate calculation.) 
            
            In this link you  can read full google help article: http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
            
            In your case syntax will be: [](http://www.example.com/files/map.pdf)
            
             [Then go to analytics to "Content" section  of the reports and view Event Tracking an you will have:
            
            category: PDF
            
            Action: Download
            
            label: MyMap
            
            and count .... count how many events you have
            
            Wish you a huge number of downloads.
            
            M.](http://www.example.com/files/map.pdf)
            1 Reply Last reply Reply Quote 1
            • mad2k
              mad2k @Nightwing last edited by

              It does not look right cos it was a virtual pageview tracking or mixture of both methods.

              _trackPageview() creates a virtual directory structures and _trackEvent() creates an event...

              🙂

              1 Reply Last reply Reply Quote 0
              • Stevej24
                Stevej24 last edited by

                We track our PDF downloads via content.  This way, we know how many of each particular one were downloaded.

                mad2k 1 Reply Last reply Reply Quote 0
                • mad2k
                  mad2k @Stevej24 last edited by

                  Hi Steve,

                  Could you please tell me how? What specific technical solution you use?

                  Thanks, Marek

                  1 Reply Last reply Reply Quote 0
                  • KeriMorgret
                    KeriMorgret last edited by

                    Hi Atul,

                    Did this answer your question, or do you still have questions about this topic?

                    seoug_2005 1 Reply Last reply Reply Quote 0
                    • seoug_2005
                      seoug_2005 @KeriMorgret last edited by

                      I am still not sure about the EXACT code.  Can you please give me the code to track how many persons have downloaded PDF files from a site.

                      I will appeciate greatly

                      1 Reply Last reply Reply Quote 0
                      • mad2k
                        mad2k last edited by

                        Hi again,

                        First you should decide about tracking method. Next read Google article and finally ask us a specific not general question. I think it is fair advise 🙂

                        seoug_2005 1 Reply Last reply Reply Quote 0
                        • seoug_2005
                          seoug_2005 @mad2k last edited by

                          Ok. Let me be very specific

                          You gave me the code -

                          [1. What does files/map.pdf  means ?

                          2.  Is label MyMap necessary or i can omit it

                          Thanks a lot for your patience :)](http://www.example.com/files/map.pdf)

                          1 Reply Last reply Reply Quote 0
                          • mad2k
                            mad2k last edited by

                            Hi,

                            ad. 1it's part of url - address of file you have on serwer (to download) obviously it's example you can named it different 🙂

                            ad. 2 it's optional - look to my answer on 31/01 🙂 and you can read it on google WT help

                            event tracking

                            Marek

                            seoug_2005 1 Reply Last reply Reply Quote 1
                            • seoug_2005
                              seoug_2005 @mad2k last edited by

                              Thanks.

                              Does the code gives me the number of downloads

                              how many persons have downloaded the PDF file or

                              how many times PDF file was downloaded.

                              mad2k 1 Reply Last reply Reply Quote 0
                              • mad2k
                                mad2k @seoug_2005 last edited by

                                I doesn't. It does you a number of views, because there's a lot different solutions in internet browsers and plugins and user can even view it in Google docs viewer. But for many purposes it is sufficient to know that user view a document.

                                You can implement dedicated java script tool to know the number of downloads. Probably the code mentioned by nvs.nim (below) realizes such an action.

                                Good luck 🙂

                                1 Reply Last reply Reply Quote 1
                                • akshaysharma20
                                  akshaysharma20 last edited by

                                  Hi Atul, Following is the response to your queries. 1). 'Map.pdf' refers to the name of the pdf and 'file' refers to the directory in which it is stored. 2). Using the above code, you would be able to track the click on the links and not the downloads. For setting up event tracking for a pdf download, I would recommend you to place the following code within the code of your download link onClick="_gaq.push(['_trackEvent', 'download', 'Pdf', 'Mypdfname',, true]);" Thus, the final download link would look like Download PDF Now that you have set up event tracking script in place, you now need to set up the event as a goal in Google Analytics. For that, follow the steps, 1. Open up the profile you wish to set up the goal in. 2. Click the gear icon in the upper right corner of the Google Analytics interface. 3. Click the Goals tab (in the sub-navigation just below where your Profile is listed) 4. Choose the Goal Set you wish to add the event to. 5. Name your goal and select the Event radio button. 6. Populate the following goal details: Category | that matches | download Action | that matches | Pdf Label | that matches | Mypdfname Value | that matches | 7. If you’ve added a Value in step 1, leave the “Use the actual Event Value” radio button selected. 8. Click “Save” and you’re ready to go! Hope, it might help! Cheers! 🙂

                                  1 Reply Last reply Reply Quote 0
                                  • 1 / 1
                                  • First post
                                    Last post
                                  • Site address change: new site isn't showing up in Google, old site is gone.
                                    GlobeRunner
                                    GlobeRunner
                                    0
                                    5
                                    107

                                  • One robots.txt file for multiple sites?
                                    RyanPurkey
                                    RyanPurkey
                                    0
                                    4
                                    1.1k

                                  • Off-site company blog linking to company site or blog incorporated into the company site?
                                    TheKatzMeow
                                    TheKatzMeow
                                    0
                                    6
                                    113

                                  • Has anyone tested or knows whether it makes a difference to upload a disavow file to both www. and non-www. versions of your site in GWMT?
                                    Chris661
                                    Chris661
                                    0
                                    3
                                    120

                                  • Can the Hosting location of image files have a negative effect if on the developers own media server rather than on client site server ?
                                    ReferralCandy
                                    ReferralCandy
                                    0
                                    3
                                    141

                                  • How ro write a robots txt file to point to your site map
                                    Nightwing
                                    Nightwing
                                    0
                                    4
                                    8.7k

                                  • Use of Robots.txt file on a job site
                                    jennita
                                    jennita
                                    0
                                    5
                                    850

                                  • Dynamically-generated .PDF files, instead of normal pages, indexed by and ranking in Google
                                    TheEspresseo
                                    TheEspresseo
                                    0
                                    3
                                    1.0k

                                  Get started with Moz Pro!

                                  Unlock the power of advanced SEO tools and data-driven insights.

                                  Start my free trial
                                  Products
                                  • Moz Pro
                                  • Moz Local
                                  • Moz API
                                  • Moz Data
                                  • STAT
                                  • Product Updates
                                  Moz Solutions
                                  • SMB Solutions
                                  • Agency Solutions
                                  • Enterprise Solutions
                                  • Digital Marketers
                                  Free SEO Tools
                                  • Domain Authority Checker
                                  • Link Explorer
                                  • Keyword Explorer
                                  • Competitive Research
                                  • Brand Authority Checker
                                  • Local Citation Checker
                                  • MozBar Extension
                                  • MozCast
                                  Resources
                                  • Blog
                                  • SEO Learning Center
                                  • Help Hub
                                  • Beginner's Guide to SEO
                                  • How-to Guides
                                  • Moz Academy
                                  • API Docs
                                  About Moz
                                  • About
                                  • Team
                                  • Careers
                                  • Contact
                                  Why Moz
                                  • Case Studies
                                  • Testimonials
                                  Get Involved
                                  • Become an Affiliate
                                  • MozCon
                                  • Webinars
                                  • Practical Marketer Series
                                  • MozPod
                                  Connect with us

                                  Contact the Help team

                                  Join our newsletter
                                  Moz logo
                                  © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                                  • Accessibility
                                  • Terms of Use
                                  • Privacy