diff --git a/PowerSupplyUtilities/R/create_google_display_event_log.r b/PowerSupplyUtilities/R/create_google_display_event_log.r index bdeeb02..dc29372 100644 --- a/PowerSupplyUtilities/R/create_google_display_event_log.r +++ b/PowerSupplyUtilities/R/create_google_display_event_log.r @@ -23,7 +23,7 @@ create_google_display_event_log <- function(from=Sys.Date(), # Retrieve revenue data db_transactions <- get_transactions_data(from=from, to=to) - #db_influencer_metrics <- get_referrals_data(from=from, to=to) + db_influencer_metrics <- get_referrals_data(from=from, to=to) db_first_transactions <- get_first_transaction_dates_for_users(from=from, to=to, users=db_transactions$app_user_id) # Join Mixpanel Conversion Data with transaction data diff --git a/PowerSupplyUtilities/R/search_engine_marketing_report.r b/PowerSupplyUtilities/R/search_engine_marketing_report.r index e535879..71c6375 100644 --- a/PowerSupplyUtilities/R/search_engine_marketing_report.r +++ b/PowerSupplyUtilities/R/search_engine_marketing_report.r @@ -57,6 +57,8 @@ search_engine_marketing_report <- function( adwords_keywords_elog=NULL, AdWordsUtilities::overall_performance_over_time(gdn_elog) AdWordsUtilities::desktop_gdn_performance_over_time(gdn_elog) AdWordsUtilities::mobile_gdn_performance_over_time(gdn_elog) + PowerSupplyUtilities::orders_per_week(gdn_elog, + campaign_filter="Rmktg") } diff --git a/transactions_query.sql b/transactions_query.sql index 68a57d6..220eb34 100644 --- a/transactions_query.sql +++ b/transactions_query.sql @@ -3,7 +3,7 @@ , u.name as user_name , u.id as app_user_id , t.discount_amount - , ti.credit_used + , t.credit , t.sales_tax_amount , (CASE t.refunded WHEN 't' THEN @@ -17,12 +17,15 @@ ELSE ti.price - t.sales_tax_amount + t.discount_amount END) as retail_price - , (CASE t.refunded - WHEN 't' THEN - 0 - ELSE - ti.price - ti.credit_used - END) as money_in_the_bank_paid_to_us + , (CASE + WHEN t.refunded = 't' THEN + 0 + WHEN t.credit > 0 THEN + ti.price - t.credit + ELSE + ti.price + END + ) as money_in_the_bank_paid_to_us , (CASE WHEN d.type = 'GiftCard' THEN 'Gift Card' @@ -41,5 +44,7 @@ inner join users u on t.user_id = u.id where - t.created_at between '@{start_date}' and '@{end_date}' + t.created_at between date'@{start_date}' and (date '@{end_date}' + integer '1') + and t.complete = TRUE + -- Adding 1 makes sure that no values are cut off by time zones. order by t.created_at desc" \ No newline at end of file