3D FlipBook - Track download with Google Tag Manager

a***e@gmail.com
2020-11-17
2020-11-18

Hi,

I'm trying to set up download tracking via Google Tag Manager. I have already set the tag and as trigger I'm trying to use an event in the datalayer.

This work:

function ready (scene) {
     parent.dataLayer.push ({'event': 'pdf-download'});
} ready;

The 'pdf-download' event is pushed and the tag fires. But it activates on flipbook viewing, not on pdf downloading. So now I have to intercept the click event on the download button and my knowledge of javascript is limited.

I try this:

function ready (scene) {
    $('.cmdSave a').click (function (e) {
      parent.dataLayer.push ({'event': 'pdf-download'});
    });
} ready;

It doesn't works, the event is not triggered by clicking the download button in the flipbook. Any suggestions?

Replies

a***e@gmail.com
2020-11-17
2020-11-18

ok i figured out:

function ready(scene) {
    jQuery(scene.view.getContainer()).find('.cmdSave').click(function(){
        parent.dataLayer.push({ 'event': 'pdf-download' });
    });
} ready;
a***e@gmail.com
2020-11-17
2020-11-17

Is there a way to make this change on all books and not have to do it on each one? Thanks

a***r@3dflipbook.net
2020-11-18
2020-11-18

Yes, use ready function from settings - it works globally.

Log In to leave a comment