WordPress.org

Ready to get started?Download WordPress

Forums

Email Before Download
[suggestion] Insert Google Analytics in Email Before Downlad (5 posts)

  1. Alessandro Timmi
    Member
    Posted 2 years ago #

    This is a suggestion both for users that may have my same needs, and for the developers of this great plugin. I think it could be useful because i didn't find a ready-made solution on the web.

    I needed to track the number of clicks on the "send" button, but only the good ones (that is, only when the user compiles the form correctly). To do this, I wanted to use Google Analytics event monitoring:
    _gaq.push(['_trackEvent', 'category', 'action', 'label']);

    First I noticed that Contact Form 7 has the "Additional Settings" field. It is perfect, because it executes javascripts using the event "on_sent_ok".

    So i should write, in this field:

    on_sent_ok: "_gaq.push(['_trackEvent', 'category', 'action', 'label']);"

    However, this event isn't called anymore when you install Email Before Download.

    Nevertheless, i noticed that the same event is present inside the file email-before-download.php, in the plugin folder, about line 480:
    $cf7->additional_settings = "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='The link to the file(s) has been emailed to you.'; \"";

    I modified it in this manner, adding Analytics event tracking:
    $cf7->additional_settings = "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='The link to the file(s) has been emailed to you.'; _gaq.push(['_trackEvent', 'category', 'action', 'label']); \"";

    Obviously, you have to modify the line for all the sending methods you want to use ("inline", "email" or "both"). I tested it for "email" method and seems to be ok.

    NOTICE: you must have Analytics tracking script on the HEAD tag of your page: i.e., I use "Google Analytics for WordPress" plugin by Yoast. If you exclude the Admin from Analytics reports inside Yoast settings, the click events will not be monitored too. You have to log out from WordPress to check if the event tracking is ok.

    http://wordpress.org/extend/plugins/email-before-download/

  2. nikoza
    Member
    Posted 1 year ago #

    This is an great idea for future improvements!

    @Alessandro, I would like to ask you if you have tryied to attach the event on the click of the link. I am trying to achieve this event in order ensure that I know exactly how many times the link was clicked but I cannot make it becuase of the escaping which does not work.

    I would appreciate any help offered!

    Thanx
    N.

  3. mandsconsulting
    Member
    Plugin Author

    Posted 1 year ago #

    Hi nikoza,

    Thanks for the interest to our plugin. As you may notice, the thread is quite old and we addressed this since this was originally brought up. So currently there is no need to make custom modifications of our plugin code. All you have to do is to modify the Contact Form 7 "Additional Settings" field, setting the "on_sent_ok" as follows:

    on_sent_ok: "_gaq.push(['_trackEvent', 'category', 'action', 'label']);"

    Just as Alessandro wrote in his post: “NOTICE: you must have Analytics tracking script on the HEAD tag of your page: i.e., I use "Google Analytics for WordPress" plugin by Yoast. If you exclude the Admin from Analytics reports inside Yoast settings, the click events will not be monitored too. You have to log out from WordPress to check if the event tracking is ok.”

  4. nikoza
    Member
    Posted 1 year ago #

    Hello Mandsconsulting and thank you both for your answer and for your great plugin.

    What I want to achieve is to have an event on the click of the download link, not on the submission of a form. Many people complained that when submitting the form and do not notice the generated link below the form. In this case the event will be triggered because the form was submitted even thought the link was not clicked.

    I am having a hard time with escapping the analytics code on the link. Can you please help me a bit with this if you can please?

  5. mandsconsulting
    Member
    Plugin Author

    Posted 1 year ago #

    Hi nikoza,

    Now I see what you mean. Currently no, we do not assign any event on the link clicks. But we will certainly consider adding this in a future release.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic