Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1256706

    Hi –

    I’d like to track the download a specific pdf (or two) on my site. I tried using this code in a code block (I tried to add it in a regular text link but it wasn’t working – it just defaulted without the tracking code): <a href="https:your file.pdf" target="_blank" onclick=”_gaq.push([‘_trackEvent’,’Download’,’PDF’,this.href]);>Download pdf</a>
    Is that correct?

    Is is possible to track a click on a button? I’d like the button “Downloade CADK…” on the page below to be tracked, but can’t use the code above for that. I saw something about putting a code in the functions.php in the child theme – can you help me with that? The button ID is “CADK-okt”, and I just want to track the download.
    Thanks!
    thanks
    Nancy

    • This topic was modified 4 years ago by Munford.
    #1257115

    Hey Munford,

    Here are the docs for you:

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1257648

    Hi Victoria,
    That did not answer my question.
    I need to track a specific button on my site, and want to add the code to the pdf download link, or add some code to the functions.php file to track it.
    Can anyone help me with this?
    thanks
    Nancy

    #1258539

    Hi,

    Thank you for the update.

    Where did you add the pdf link with the onclick attribute? Have you tried using the Code Block element instead of the Text Block? Please create a test page and post the site account details in the private field so that we could inspect the issue.

    You might have to replace the GA snippet with the latest version.

    // https://developers.google.com/analytics/devguides/collection/analyticsjs

    Best regards,
    Ismael

    #1262437

    Hi Ismael,
    thanks for your response. My client is now asking about the download rate but I don’t think it’s set up yet.
    I wasn’t sure how to do it with a code block and the button.
    the code I was trying to use was:
    Download pdf
    On the test page below I have the code in a code block on the right, button is on the left and that is what I would like tracked.
    Is this code correct?

    You might have to replace the GA snippet with the latest version.

    not sure how to do that. I found the new GA very confusing when I recently tried to add a new site there.
    Can you help me set this tracking up?
    thanks very much,
    Nancy

    #1263180

    Hi,

    Thank you for the update.

    Did you already create an event in your Google Tag Manager console? Instead of adding the onclick attribute to the link, try to track the button based on a custom css class or ID. There are a lot of instructions, documentation or tutorials available out there such as the following.

    // https://www.lovesdata.com/blog/google-tag-manager-button-click-tracking

    If you want to read more about tracking events, please check the documentation.

    // https://developers.google.com/analytics/devguides/collection/gtagjs/events

    And if you have not created a tracking event or goals yet, please refer to the following instructions.

    // https://support.google.com/analytics/answer/1033068#Anatomy
    // https://support.google.com/analytics/answer/1032415

    Best regards,
    Ismael

    #1263273

    thanks very much, I’ll check all that out.
    When I am inserting the Google Tag Manager in the <head> tag – where is the best place to do that?
    And where do I put the code that does in the >body> tag?

    • This reply was modified 3 years, 12 months ago by Munford.
    #1263636

    Hi,

    Thanks for the update. If you need to place code in the header, then it should work if you paste the script in the Google Analytics box in the theme options. If it doesn’t work there, then please use a function in your functions.php file instead:

    function add_tag_manager_script(){
    ?>
    Code in the header goes here
    <?php
    }
    add_action('wp_head', 'add_tag_manager_script');

    If you need to add code below the body tag, then please use this:

    function add_script_below_body_tag(){
    ?>
    Code below the body tag goes here
    <?php
    }
    add_action('ava_after_body_opening_tag', 'add_script_below_body_tag');

    Best regards,
    Rikard

    #1277102

    I am still having problems understanding how to do this tracking, and my client will soon be adding more links and podcasts they want tracked. Should I only be dealing with Google Tag Manager? I walked through the tutorial but was not successful. Is there an easier way to do this – through a plugin or something? I find the tag manager really confusing. I saw that MonsterInsights pro can track downloads easily from the admin. Are you familiar with that plugin and are there any downsides to using it?
    thanks
    Nancy

    • This reply was modified 3 years, 9 months ago by Munford.
    #1277229

    Hi,

    There are other tracking tools out there such Matomo or Hotjar, but the most popular and maybe the easier to implement is Google Analytics because all the options that you need are already in the console, which has a very good UI. All you need to do is create a goal and set up the triggers or conditions e.g., click, scroll, DOM changes, form submission etc., to track an event.

    Here is a good tutorial on how to track Google Tag Manager events.

    // https://medium.com/analytics-for-humans/how-to-track-events-on-your-website-with-google-tag-manager-c9c4a510c77c

    Best regards,
    Ismael

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.