Analytics
2.5K members online now
2.5K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

How to track Virtual Page & PDF Click and Download

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Howdy there,

 
We have two separate goals on each of the product pages say "Contact sales form" and "download PDF", I want to track these two goals in GA.  
 
Challenge is, after submit the contact form, there's no separate 'thank you' page created, it's a wordpress website and form details submit under the Java script or on virtual page, how do I track them in GA?
 
Second, how do track .pdf clicks/download and send pageviews to GA?
 
Anybody about with a quick answer? Greatly appreciated. 
1 Expert replyverified_user

Re: How to track Virtual Page & PDF Click and Download

[ Edited ]
Top Contributor
# 2
Top Contributor

Are you using a plugin for the forms? If so which one?

re the pdf link on the page..if you want to track it as a virtual pageview .. you can add some extra code to the link to send a virtual pageview to GA

eg

<a href="http://mydomain.com/somepath/filename.pdf" onclick="ga('send', 'pageview', '/somepath/filename.pdf');
">Download PDF</a>

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

How to track Virtual Page &amp; PDF Click and Download

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Thanks Bronwyn for your reply. 

 

I'm using gravity form for contact inquiry on wordpress. Inside the WP admin, I can see the users have submitted information and I do receive form inquiry email notification but how to track them in GA? As it's not a separate thank you page. 

 

Re. pdf link, we have thousand product pages containing this download pdf link for product specification, example https://www.ergocentricstore.com/product/tcentric-hybrid-desk-chair/ it's difficult to replace link with the code, is there any way to track the pdf either download or just clicks on any product pages? 

 

 

How to track Virtual Page &amp; PDF Click and Download

Top Contributor
# 4
Top Contributor

Hi :-)

Regarding gravity forms, I've not used it in eons. This will likely help you get the ga tracking sorted out though

https://www.doitwithwp.com/track-conversions-gravity-forms-google-analytics/

Are you specifically wanting to track the pdf downloads as virtual pageviews, or do you have the option to track them as events instead?


Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

How to track Virtual Page &amp; PDF Click and Download

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Thanks for this post, it's great. I'll find out how I can implement it as well. 

 

I just need to track PDF button clicks, so I guess track 'em as an events would be fine. Do I need to do in GTM? If so, how exactly I can create the triggers for PDF button click and view in GA? 

How to track Virtual Page &amp; PDF Click and Download

[ Edited ]
Top Contributor
# 6
Top Contributor

Just to clarify..you are using Google Analytics tracking code snippet.
not Google Tag Manager with a GA tag setup for site tracking within GTM

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: How to track Virtual Page &amp; PDF Click and Download

[ Edited ]
Participant ✭ ✭ ✭
# 7
Participant ✭ ✭ ✭

Great advice from @Bronwyn V, just as always. Smiley Happy

 

Just a quick sidenote - if you're running GTM on your site, you can use this receipt to track clicks on different file download links: http://www.lunametrics.com/labs/recipes/file-download-links/

 

I think it's the easiest way to start tracking clicks on download links on your website. But if you're not running GTM on your site, you cannot use it like Bronwyn already mentioned. I personally prefer using GTM.

 

Cheers,

Taavi

How to track Virtual Page &amp; PDF Click and Download

[ Edited ]
Top Contributor
# 8
Top Contributor

In regards to tracking the download links.
Since it is wordpress, if you use a plugin to add the tracking code, the following one tracks downloads 

without any additional edits to links on pages being made
I've used it one on and off for a couple of years without issues (Im not affiliated with them in any way).

https://wordpress.org/plugins/google-analytics-dashboard-for-wp/

 

Keep in mind, if you use a plugin then you will also need to remember to remove the current tracking code snippet from the website as the plugin will replace it and put it in the <head></head> section as per installation recommendations.

 

eta.. you can also do as @Taavi Kalvi suggests and swap over to using GTM setup with a GA tag instead.

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

How to track Virtual Page &amp; PDF Click and Download

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

Hey guys, thanks for taking time to help me out here. 

 

I've already GA code installed across the website and there's no way make sense to replace code by using other method. As far as I know GTM has such a facility to create GA tag (using existing GA ID) and add various triggers and variables to track any damn thing on the website.

 

But here I need your help how exactly do I create tag/triggers in order to track the PDF button clicks? Like this? https://www.ergocentricstore.com/product/tcentric-hybrid-desk-chair/

 

OR is there any other way out-of-the GTM?   

 

Re: How to track Virtual Page &amp; PDF Click and Download

Top Contributor
# 10
Top Contributor

If you put the following code after your GA tracking code snippet, it should automatically track the pdfs as events

<script type='text/javascript'>
if (typeof jQuery != 'undefined') {
    var filetypes = /\.(pdf)$/i;
    var baseHref = '';
    if (jQuery('base').attr('href') != undefined) baseHref = jQuery('base').attr('href');
    var hrefRedirect = '';
 
    jQuery('body').on('click', 'a', function(event) {
        var el = jQuery(this);
        var track = true;
        var href = (typeof(el.attr('href')) != 'undefined' ) ? el.attr('href') : '';
        var isThisDomain = href.match(document.domain.split('.').reverse()[1] + '.' + document.domain.split('.').reverse()[0]);
        if (!href.match(/^javascript&colon;/i)) {
            var elEv = []; elEv.value=0, elEv.non_i=false;
            if (href.match(filetypes)) {
                var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined;
                elEv.category = 'download';
                elEv.action = 'click-' + extension[0];
                elEv.label = href.replace(/ /g,'-');
                elEv.loc = baseHref + href;
            }
            else track = false;
 
            if (track) {
                var ret = true;
 
                if((elEv.category == 'download') && (el.attr('target') == undefined || el.attr('target').toLowerCase() != '_blank') ) {
                    hrefRedirect = elEv.loc;
 
                    ga('send','event', elEv.category.toLowerCase(),elEv.action.toLowerCase(),elEv.label.toLowerCase(),elEv.value,{
                        'nonInteraction': elEv.non_i ,
                        'hitCallback':gaHitCallbackHandler
                    });
 
                    ret = false;
                }
                else {
                    ga('send','event', elEv.category.toLowerCase(),elEv.action.toLowerCase(),elEv.label.toLowerCase(),elEv.value,{
                        'nonInteraction': elEv.non_i
                    });
                }
 
                return ret;
            }
        }
    });
 
    gaHitCallbackHandler = function() {
        window.location.href = hrefRedirect;
    }
}
</script>

It will show in the event reports as 
Event Category - download

Event Action - click-pdf

Event Label - url to the pdf

 

Its been modified a little from this one to take out some of the extra code.

http://www.blastam.com/blog/howto-track-downloads-links-universalanalytics

If you use their script without changes, then it will also track mailto email links, tel click to call links

and outgoing links to other sites as well as a number of file types aside from pdfs if the links to them are present

 

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here