Last active
July 8, 2022 16:23
-
-
Save groggu/a442e4a0a450dadad1e54bc79f63d58c to your computer and use it in GitHub Desktop.
Reports for ThirstyAffiliates WordPress plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Click details for last 7 days | |
SELECT | |
wp_posts.post_title as 'Link Name' , | |
wp_ta_link_clicks.date_clicked , | |
ip.meta_value as 'User IP Address', | |
redirect.meta_value as 'Affiliate Link', | |
cloaked.meta_value as 'Cloaked Link' | |
FROM | |
wp_ta_link_clicks | |
JOIN wp_posts ON wp_ta_link_clicks.link_id = wp_posts.ID | |
JOIN wp_ta_link_clicks_meta AS ip ON wp_ta_link_clicks.id = ip.click_id AND ip.meta_key ='user_ip_address' | |
JOIN wp_ta_link_clicks_meta AS redirect ON wp_ta_link_clicks.id = redirect.click_id AND redirect.meta_key ='redirect_url' | |
JOIN wp_ta_link_clicks_meta AS cloaked ON wp_ta_link_clicks.id = cloaked.click_id AND cloaked.meta_key ='cloaked_url' | |
WHERE | |
DATE(date_clicked) > DATE_SUB(CURRENT_DATE , INTERVAL 7 DAY) | |
#TA Click Count | |
SELECT | |
wp_posts.post_title AS post , | |
DATE(date_clicked) AS date , | |
COUNT(*) AS clicks | |
FROM | |
wp_ta_link_clicks | |
JOIN wp_posts ON wp_ta_link_clicks.link_id = wp_posts.ID | |
WHERE | |
DATE(date_clicked) > DATE_SUB(CURRENT_DATE , INTERVAL 7 DAY) | |
GROUP BY | |
wp_posts.post_title , | |
DATE(date_clicked) | |
ORDER BY | |
post_title |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These are for the free version of the ThirstyAffiliates WordPress Plugin.
To execute these SQL scripts, connect to your WP database
Tested in TA plugin version 3.10.11, should work in version 3.10 or above