Movatterモバイル変換


[0]ホーム

URL:


tutorial

library(redditadsR)library(dplyr)#>#> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#>#>     filter, lag#> The following objects are masked from 'package:base':#>#>     intersect, setdiff, setequal, unionlibrary(ggplot2)

Goal

The goal here is to outline in a couple of paragraphs and few linesof code some simple ways in which we can use theWindsor.ai API andR packageredditadsR to gain insights into marketing campaignperformance in Reddit Ads. The nice thing about Windsor.ai is that youcan have all of your marketing channels aggregating in a single placeand then access all data at once using this package. In this case,however, the package is focused on getting data from reddit Adscampaigns. Of course, once the data is inR you can do muchmore than the examples below, and work on analysis, predictions ordashboards.

Getting data from Reddit Ads into R

After we create an account atWindsor.ai and obtain anAPI key, collecting our data from Windsor to R is as easy as:

my_redditads_data<-fetch_redditads(api_key ="your api key",date_from =Sys.Date()-100,date_to =Sys.Date(),fields =c("campaign","clicks","spend","impressions","date"))

This code will collect data for the last 100 days. Lets take a lookat the data we just downloaded to get a better idea about the structureand type of information included.

str(my_redditads_data)#> 'data.frame':    14 obs. of  5 variables:#>  $ campaign   : chr  "retageting APAC" "retargeting UK&CO" "retageting APAC" "retargeting UK&CO" ...#>  $ clicks     : num  4 0 5 7 0 0 4 2 3 0 ...#>  $ spend      : num  2.57 2.48 2.39 2.54 0.94 0.71 2.59 2.12 2.43 0.13 ...#>  $ impressions: num  806 693 819 689 299 190 682 688 822 135 ...#>  $ date       : chr  "2022-09-28" "2022-09-28" "2022-09-29" "2022-09-29" ...

Analyzing our Reddit and Reddit Ads campaign data

Now we can analyze our Reddit Ads data. For instance, let’s comparethe two campaings we have to see which one performed better the last 100days.

ggplot(my_redditads_data,aes(y = clicks,fill = campaign))+geom_boxplot()

It looks like APAC campaign is performing better than UK&CO innumber of clicks. Now let’s see if this difference is statisticallysignificant by using generalized linear models, as our variable responseis number of clicks, which have a poisson distribution.

lmod<-glm(clicks~ campaign,data = my_redditads_data,family ="poisson")summary(lmod)#>#> Call:#> glm(formula = clicks ~ campaign, family = "poisson", data = my_redditads_data)#>#> Deviance Residuals:#>     Min       1Q   Median       3Q      Max#> -2.3905  -1.6036  -0.7599   0.6372   3.5065#>#> Coefficients:#>                           Estimate Std. Error z value Pr(>|z|)#> (Intercept)                 1.0498     0.2236   4.695 2.67e-06 ***#> campaignretargeting UK&CO  -0.7985     0.4014  -1.989   0.0467 *#> ---#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1#>#> (Dispersion parameter for poisson family taken to be 1)#>#>     Null deviance: 43.735  on 13  degrees of freedom#> Residual deviance: 39.456  on 12  degrees of freedom#> AIC: 66.147#>#> Number of Fisher Scoring iterations: 6

We can see that differences among campaigns are statisticallysignificant and that the campaign UK&CO have a mean that is 0.79lower than the APAC campaign.


[8]ページ先頭

©2009-2025 Movatter.jp