Using R and Google Analytics for Online Marketing Improvements

Picture of Lillian Pierson, P.E.

Lillian Pierson, P.E.

Reading Time: 9 minutes

5 Easy Steps to Using R and Google Analytics for Online Marketing Improvements

Using R and Google Analytics for Online MarketingDo you want to use your data to improve the results of your online efforts? Do you think analytics and data science are too sophisticated for you at this time? Well, don’t let the brainiacs fool you! Extracting valuable insights from your data isn’t that complicated!! In this article, I’ll show you how to make a quick start in using R amd Google Analytics for online marketing improvements.

These 5 easy steps will give you a leg up by providing you the code you’ll need to do this analysis for yourself. I give you a demonstration of how I carried out this evaluation for my brand, and end by explaining to you EXACTLY why it’s preferable to do this in R, rather than use plain Google Analytics.

Step 1: Document The Recent Events That Are Likely to Impact Your Data & Conversions

Ok, so I am going to keep this step discussion brief, and then after we get you through this part, I’ll show you how I applied these steps to optimize my own online marketing efforts.

For the first step in using R and Google Analytics for online marketing improvements, you want to take a little time to form a solid idea about what you expect your data and results will look like.

  1. Clarify your goals, and decide what metrics that you think will be most relevant to measuring progress towards reaching those goals.
  2. Also, list the initiatives or occurrences that have happened recently, how you think they will impact your data, and the approximate date on which these events occurred. When I say “initiatives or occurrences”, I am referring to things like: social advertisement campaigns, Google Ads campaigns, inbound marketing campaigns, SEO initiatives, website attacks, email marketing campaigns, etc.
  3. Lastly, document what you consider to be an event, or user action that constitutes a conversion for your brand. Examples of events include: social follows, email subscriptions, downloads, purchases, site subscriptions, etc.

Enjoying seeing how to start using R and Google Analytics for online marketing improvements?

If so, you’d probably really get a lot out of our full scale course, R Programming for Data Science. We’ve made that available online here. The Mastery Level option even gives you a chance to interact directly with the instructor and your peers. You can see more about it here.


Step 2: Download Your Google Analytics Data Using the Google Analytics API

Authorizing the connection with the Google Analytics API was the trickiest part of this process for me – mostly because you have to go outside of R to get all the permissions set up. I am giving you my code and I also want to point you to the web page that I used to figure out this process. They’ve made it pretty straight forward, actually.

Set up your Google Analytics API client ID and secret by following the instructions on this page.


step-1

Download the R Scripts to connect to the Google API for free here.


.

.

.

Step 3: Organize & Explore Your Data

Now it is time to organize your data and take a look around. How do the results look compared to what you expected? Are there any results that appear out of place from your expectations? When did these events occur? What might have caused them? Does the data show me metrics that might better reflect progress towards your intended goals?


step-2

Download the R Scripts to do organize & explore your Google Analytics data for free here.


.

.

.

Step 4: Select the Metrics that Best Represent Progress Towards Business Goals & Generate Data Visualizations

After exploring your data, what metrics best reflect progress towards your business goals? On your list of goals, next to each goal, write down the name of the metric(s) that best measures progress.

Now once again consider your goals… are they realistic? Do they need to be adjusted down or up based on what the data is telling you about current and historical performance?

Lastly, create a few visualizations that clearly demonstrate what your seeing in your data. Make sure to use the metrics that you decide are the best measures of true progress (rather than the ones you had suspected would be good in Step 1). You’ll want to design your data visualizations so that they most clearly emphasize the points you will be making when you communicate your recommendations to your team members.


organizing google analytics data with r

Download the R Scripts to visualize your Google Analytics data for free here.


.

.

.

Step 5: Decide How These Insights Affect Your Plans & Communicate Conclusions To Team Members

Which of your initiatives are showing the greatest impact? Which are under-performing? Are there underlying issues that you need to resolve to get your business closer to its goals?

In general it is best to follow the 80-20 rule with online marketing. Identify what new initiatives are showing spectacular performance (this would be equivalent to 2 out of 10 initiatives). Scrap whatever initiatives aren’t within the top 20% performance range.

Now take the resources you would have allocated to the lower 80% initiatives, and use it to do both of the following:
  1. Increase resource allocations to the top 20% performers
  2. Invest resources into experimenting with new initiatives (with the goal of finding more high performance methods

Draft a plan. Support your recommendations with data visualizations, tables, and written discussion. Describe logistical details about future implementations. Maybe even add in an addendum for your support staff, and use this addendum to provide them links and access permissions they will need to execute the work from here moving forward.

The goal of this plan is to clarify and communicate exactly what needs to be done, how, and why – so that you can keep your business moving towards its desired objectives.

Extra Credit Step: Congratulate Yourself for Making a Start in Using R and Google Analytics for Online Marketing Improvements

And there you have it. You’ve just seen how quick and simple it can be to start using R and Google Analytics for online marketing improvements. Pat yourself on the back. Now it’s your turn!!


Now it’s time to see how this plan is executed.

Final-Plot

 

The first thing I need to do is make some quick lists of goals, metrics, and recent events (with dates) that are likely to impact my brand’s data and conversions.

Goals

  • Email Subscription Increases (500/mo)
  • Website Visitors (300/mo increase on avg)
  • Improved Audience Targeting
  • Streamline Internal SEO
  • Optimize Social Marketing Efforts
  • Product Sales Revenues ($Xk/mo)
  • Services Revenues ($Xk/yr)

Relevant Metrics

  • Emails Signups / Month
  • Number of Site Visits
  • Number of Page Views
  • Number of Sessions from SEO
  • Number of Sessions from Social
  • Number of Revenue-Generating Conversions

Recent Events

  • Book Giveaway (May 2015)
  • Book Launch (March 2015)
  • SWSX Speaking Engagement (March 2015)
  • IBM Online Influencer Event (Aug 2015)
  • Facebook Advertising (May 2015 – Present)
  • New High-Value Content Marketing Approach (May 2015 – Present)
  • Referral Spam Attack on Site (Aug 2015)

After carrying out the Step 2 work in RStudio, I got into exploring and analyzing my Google Analytics data. I answer the following brief questions:

Are the results similar compared to what you expected?

Sort of, but there are a few surprises. When exploring my data, I quickly realized that it is best to measure page views derived from Facebook, to measure the effectiveness of my ad campaigns. Number of page views is the true measure of how interested visitors are in what you’re offering. I was also hoping to see better improvements in my SEO results.

Are there any results that appear out of place from your expectations? When did these events occur? What might have caused them?

I am surprised at:
  • How effective my Facebook advertising has been at attracting people that are truly interested in what I am doing with this brand – (May – Present) – Caused by advertising to the people most likely to be interested in Data-Mania, and by offering them free products that they can use to help them advance their careers.
  • How little traffic came from Twitter during the first few months of 2015 – (Jan – Feb) – I was finishing my book project and was a little burnt out on producing new content for the blog. The decrease is almost certainly because of a decrease in content marketing efforts.
  • The 6-fold increase in site visitors that I have gotten during a few months this year (May – Present) – People really respond positively to high-value content given away for free. Facebook is an excellent avenue for acquiring new, well-fit users
  • The amount of traffic that came from SEO in August – (Aug) – Most of that was due to the high-value content published that month, but I also got referral spam that offset the numbers that month too. I had a Joomla CMS sitting in my root directory and it got spammed with referral traffic. This event spurned me to finally take action and fix the fundamental issues in the CMSs on my site.

Does the data show me metrics that might better reflect progress towards your intended goals?

Yes

  • For Facebook advertising, the number of page views (rather than the number of site visits) generated from Facebook referrals is a far better metric for measuring the effectiveness of ad campaigns.

Now, it’s time for me complete step 4 of this process. I am not comfortable delving deeper into the financial aspects of my business online, but I will be happy to discuss the other areas I evaluated.

Goals – Finalized Metric Selections

  • Email Subscription Increases (500/mo)
  • Website Visitors (300/mo increase on avg) – Metric to Track = Number of Total Sessions
  • Improved Audience Targeting – Metric to Track = Number of Page Views
  • Streamline Internal SEO – Number of Sessions from SEO
  • Optimize Social Marketing Efforts – Number of Sessions from Twitter, Number of Page Views from Facebook

Now once again consider your goals… are they realistic? 

Yes

Lastly, create a few visualizations that clearly demonstrate what your seeing in your data.

Final-Plot

Lastly, it is time for me to decide what I want to do with all this information I gathered. (Please keep in mind that I ran this analysis several months ago as a starter, and have already made some of these changes).

After using R and Google Analytics for online marketing improvements, I’ve made the following decisions:
  • Increase resources spent on Facebook advertising.
  • Hire someone to fix my CMS issues and the referral spam problem
  • Tip of the Day content didn’t have any real impact, so discontinue that
  • Fire the SEO guy that is helping me (I did that in July)
  • Hire someone to spruce up my onpage SEO only
  • Make sure to keep posting content from my site onto Twitter. Even old content can be extremely high-value to people that have not seen it yet. Topics that are not time-sensitive will be just fine to recycle through the social streams for guests to learn from. Have my assistant make a list of these articles and draft up headlines with URLs for social scheduling. Try to do this in one sitting, so that it can be handled for an entire year and I can be free to focus on other high-impact avenues.
  • SEO doesn’t appear to be a real winner in the portfolio, and I don’t anticipate great ROI from the SEO onsite fixes. Once this is done, I should let SEO efforts go and focus on another channel. Flipboard appears to be quite promising.

I will spare ya’ll the write up… and honestly, this marketing project is so small still, I don’t really need one. The point is that I have made some strategic decisions based on Google Analytics, and I expect these decisions will lead me to less waste, and greater impact with my marketing efforts in the future. This is a wash, rinse, repeat process.

Carry it out every 6 months and watch your brand start moving quickly in the right direction.


Why It’s Better To Do This in R

The thing about Google Analytics is that the data and metrics are spread out on different pages. You can get your data visualizations only in the bundling and packages by which GA bundles them. Google Analytics does offer a dashboard application where you can build your own custom Google Analytics dashboard, but it’s not easy or flexible. You’d probably have to take a course just to figure out how to build a dashboard with the exact metrics you need (if you could at all).

To make a clear decision about what’s working and what’s not, you need to see the metrics compared side-by-side. Considering what you know about how much time and money you’re spending on your branded space; the snapshot comparative view is super helpful in telling you whether that time and money is well spent.

To get this view of your data and metrics, all you need to do is build a custom report / visualization. That’s where R comes in. R is a great choice for this task because it is so quick and easy to do this type of analysis using R (and R is FREE).

The following are a few of the benefits derived from doing this work in R.

  • R is free of cost.
  • You can get immediate updated results, over and over, once you’ve got the script built.
  • It is easy to build scripts in R.
  • R is well-supported and documented, if you get stuck just Google it.
  • R can be used for real-time reporting
  • There is no clunky cargo, name only the data you need, and extract/process it automatically after the scripts are built.
  • With just a few hours invested upfront, you’ll have automated analysis and visualization tasks that would take days if performed manually each time you need to do an update.

Enjoyed seeing how to start using R and Google Analytics for online marketing improvements?

If so, you’d probably really get a lot out of our full scale course, R Programming for Data Science. We’ve made that available online here. The Mastery Level option even gives you a chance to interact directly with the instructor and your peers. You can see more about it here.


Share Now:
HI, I’M LILLIAN PIERSON.
I’m a fractional CMO that specializes in go-to-market and product-led growth for B2B tech companies.
Apply To Work Together
If you’re looking for marketing strategy and leadership support with a proven track record of driving breakthrough growth for B2B tech startups and consultancies, you’re in the right place. Over the last decade, I’ve supported the growth of 30% of Fortune 10 companies, and more tech startups than you can shake a stick at. I stay very busy, but I’m currently able to accommodate a handful of select new clients. Visit this page to learn more about how I can help you and to book a time for us to speak directly.
Get Featured

We love helping tech brands gain
exposure and brand awareness among our active audience of 530,000 data professionals. If you’d like to explore our alternatives for brand partnerships and content collaborations, you can reach out directly on this page and book a time to speak.

Join The Convergence Newsletter
See what 26,000 other founders, leaders, and operators have discovered from the advanced AI-led growth initiatives, data-driven marketing strategies & executive insights that I only share inside this free community newsletter.
HI, I’M LILLIAN PIERSON.
I’m a fractional CMO that specializes in go-to-market and product-led growth for B2B tech companies.
Apply To Work Together
If you’re looking for marketing strategy and leadership support with a proven track record of driving breakthrough growth for B2B tech startups and consultancies, you’re in the right place. Over the last decade, I’ve supported the growth of 30% of Fortune 10 companies, and more tech startups than you can shake a stick at. I stay very busy, but I’m currently able to accommodate a handful of select new clients. Visit this page to learn more about how I can help you and to book a time for us to speak directly.
Get Featured
We love helping tech brands gain exposure and brand awareness among our active audience of 530,000 data professionals. If you’d like to explore our alternatives for brand partnerships and content collaborations, you can reach out directly on this page and book a time to speak.
Join The Convergence Newsletter
See what 26,000 other data professionals have discovered from the powerful data science, AI, and data strategy advice that’s only available inside this free community newsletter.
By subscribing you agree to Substack’s Terms of Use, our Privacy Policy and our Information collection notice