Title: Analytics and tracking
Last modified: May 25, 2020

---

# Analytics and tracking

 *  Resolved [gorky5](https://wordpress.org/support/users/gorky5/)
 * (@gorky5)
 * [6 years ago](https://wordpress.org/support/topic/analytics-and-tracking/)
 * Hi. I’m using this plugin and it seems to do the job well, and I’m close to buying
   the paid add-on for CSV exporting.
 * I’m having trouble with one thing, though: tracking the file downloads in Google
   Analytics. I know the plugin displays IP addresses but I’d like to see geographical
   spread, time, etc.
 * To add Analytics tracking I’d normally amend the link to something like this:
 * `<a onclick="ga('send', 'event', 'Downloads', 'Click', 'PDF downloaded', '0');"
   href="https://example.com/filename.pdf">Download Link</a>`
 * There doesn’t seem to be an easy way to do this, because the plugin download 
   link is dynamically generated, e.g.:
 * `https://example.com/?file=filename.pdf&nonce=5e90fca2bd03e4cec&email=address%
   40gmail.com`
 * Anyway, if I try to add tracking code in the Customize Messages page, the plugin
   strips everything out apart from the basic link. Is it possible to use custom
   hooks as a workaround, and if so, what would be needed?
 * If you have any other idea how I might implement Analytics, or view more detailed
   data on where and when people are downloading the files, please let me know.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [mkscripts](https://wordpress.org/support/users/mkscripts/)
 * (@mkscripts)
 * [6 years ago](https://wordpress.org/support/topic/analytics-and-tracking/#post-12908134)
 * Hi,
 * Yes, there is a filter available to adjust the email message including the download
   link (/wp-content/plugins/download-after-email/includes/shortcodes.php).
 * `$message = apply_filters( 'dae_email_message', $message, $values, $messages['
   email_content'], $file, $download_url );`
 * If you are using the placeholder {download_link} in your email message, you can
   replace this placeholder with your custom download link.
 * If you have any more questions, feel free to ask.
 * Kind regards,
    Team Download After Email
 *  [soytandem](https://wordpress.org/support/users/soytandem/)
 * (@soytandem)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/analytics-and-tracking/#post-13673426)
 * Hi!
    I’m looking for the same thing, add the Google tracking code, but I couldn’t
   understand the [@mkscripts](https://wordpress.org/support/users/mkscripts/) answer.
   Do I have to edit ‘shortcodes.php’ file and then change what? Sorry, I’m not 
   an expert and I’m stuck with this since I have 6 downloads to track. Could you
   help me? Thanks in advance!
 *  Plugin Author [mkscripts](https://wordpress.org/support/users/mkscripts/)
 * (@mkscripts)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/analytics-and-tracking/#post-13879284)
 * Hi,
 * Below an example of the use of the above-mentioned filter:
 *     ```
       add_filter( 'dae_email_message', 'my_custom_dae_download_link', 10, 5 );
       function my_custom_dae_download_link( $message, $values, $email_content, $file, $download_url ) {
   
           // Your custom download link
   
           $download_link = '<a href="' . $download_url . '">' . $file . '</a>';
   
           // Replace the placeholder {download_link} with the $download_link
   
           $message = str_replace( '{download_link}', $download_link, $message );
   
           return $message;
   
       }
       ```
   
 * (This is an example, please test it before using it on a live site.)
 * Changing the source code is not recommended, because after a plugin update these
   changes can be lost. That is why actions and filters are used to make changes
   or to add custom code. Here you can find more information about adding filters:
 * [https://developer.wordpress.org/reference/functions/add_filter/](https://developer.wordpress.org/reference/functions/add_filter/)
 * You can add this code to the functions.php of your child theme or via a custom
   plugin.
 * Kind regards,
    Team Download After Email

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Analytics and tracking’ is closed to new replies.

 * ![](https://ps.w.org/download-after-email/assets/icon-256x256.png?rev=2016027)
 * [Download After Email - Subscribe & Download Form Plugin](https://wordpress.org/plugins/download-after-email/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/download-after-email/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/download-after-email/)
 * [Active Topics](https://wordpress.org/support/plugin/download-after-email/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/download-after-email/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/download-after-email/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [mkscripts](https://wordpress.org/support/users/mkscripts/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/analytics-and-tracking/#post-13879284)
 * Status: resolved