❤️ Bloggers ❤️ "Beloved BI" ❤️ Let's get started ❤️ (For those who can make charts with Python)

image.png

Bloggers, I thought "** I want to watch blog access information better than Google Analytics on my blog page! " and " I want my own dashboard! **" Isn't it?

** Actually, it can be easily realized using a rental server. ** ** → Click here for the actual top image (https://napinavi.com/?page_id=821)

This article

-** Interested in data analysis , - Those who run a blog on a rental server **, --Would you like to run a blog on a rental server ** Those who are wondering **

We are writing to deliver ** How to make a dashboard ** on a rental server. ** Not applicable, I'm sorry m (_ _) m **

My blog environment is as follows.

--Blog software: wordpress --Server: ConoHa Wing

There are the following two types of rental servers, but ** my environment corresponds to the latter (the one with low customizability) **.

-** Freely customizable dedicated server, VPS (Virtual Private Server) ** -** Shared server where free software installation is prohibited ** (← my environment)

But don't worry. ** Even a shared server like me with a low degree of freedom of customization is okay as long as the following conditions are met! ** **

-** Python is already installed ** -** Job scheduler can be used **

** For those who are thinking of opening a blog on a rental server **. I will also introduce the time and cost of setting up my environment. Details are summarized in My Blog.

-** Time: ** ――It takes about 3 days to decide the working environment ――It takes 2-3 days to actually make a server contract and create a blog-like thing. --Several hours / week (expected) for future blog updates / maintenance -** Cost: ** --The cost of launching the blog is ** 11,296 yen (only for one year of server rental fee, including domain fee) ** --The cost of running a blog in the future is ** 11,296 yen / year (server rental cost for next year) **

The introduction has become long, but I hope that this article can deliver this content.

-** What is "loved BI"? ** ** -** How to make "loved BI" ** -** Stumble and remedy ** -** The splendor of making "loved BI" ** -** Who are you? ** **

What is "loved BI"?

"Beloved BI" in the title is a page where ** blog-related statistics ** that you and your readers want to see are updated in real time **. Although it was coined by me, the original story was impressed by Mr. Kashida's ** "loved dashboard" **, who is currently active in "Growth Camp Co., Ltd." at Mercari OB. , I named it.

If you are interested in "** Loved Dashboard **" instead of this article, please see Kashida-san's article. Thank you for reading this far.

In my "loved BI", the image shown at the beginning is updated every 5 minutes. You can access it from this page, so if you don't have an image, please take a look.

How to make "loved BI"

Here, ** on the premise that you can create simple charts using Python **, using Python

  1. ** How to collect statistical data **
  2. ** How to update charts in real time **

I would like to focus on. Regarding 1., I'm just using the Google Analytics API and Twitter API.

Next, what I made for 2. is as follows. Actually, ** my engineer level is too small and I don't use very difficult technology **, so I think that those who are familiar with it can reproduce it with just this.

無題のプレゼンテーション (3).jpg

This is the only ** specific task **. It's really easy. .. ..

  1. ** Apply for Twitter / Google Analytics API (finished in 1-2 hours!) </ Font> **
  2. ** Create a Python program that hits the Twitter / Google Analytics API (Pucking people's circles ...) </ font> **
  3. ** Create a Python program to create and save charts from the acquired data (Pour your love into it!) </ Font> **
  4. ** Embed a link to the image on the "Beloved BI" page (ending in seconds) </ font> **

For the time being, I will also explain the outline of each.

1. Apply to use Twitter API / Google Analytics API

Regarding Twitter, we have posted functions that can be used and reference links on My Blog. Regarding Google, I referred to the following article.

-Even beginners can understand! How to use Google Analytics API

In addition, I heard rumors that Google Analytics content can not be posted, but according to the following article, it seems that it can be published.

-Google Analytics screenshots are really NG! ?? I asked the person in charge.

2. Create a Python program that hits the Twitter API / Google Analytics API

As for Twitter, as in 1., it is summarized in My Blog. Regarding Google, I thought that the program in the following article was excellent in customization, so I borrowed it as it is.

-Get page / day PV / AdSense revenue with Google Analytics API

3. Create a Python program to create and save charts from the acquired data

** It is the most important part that influences "whether you can love". ** ** Aside from technical issues, start by thinking about what numbers you need to know and what numbers your readers are interested in. If the above is considered, the final form will be different for each blog. For your reference, I would like to list the points I thought about when designing the "loved chart".

――What is the KGI (Key Goal Indicator) of your blog in the first place? ――What should you check on a daily, weekly, or monthly basis to achieve KGI? ――Where is the itch that cannot be reached with Google Analytics or Twitter Analytics?

4. Embed a link to the image on the "Beloved BI" page

Just paste the image link like this. It's easy. image.png

Stumble and remedy

The things that stumbled are as follows.

-** The code doesn't work when I run it with the job scheduler ** -** Japanese characters are garbled with Matplotlib, but fonts cannot be installed ** -** It's hard to code on the rental server **

Here's how to deal with it. We hope for your reference.

The code doesn't work when I run it with the job scheduler

** When I was running python [working thing] .py, it moved and spit out the image, but when I registered the command in the job scheduler, the image update stopped. ** **

If this happens, make sure that the ** python command name, the python file name to be executed, and the directory name contained in the python file (especially the output destination of the image) are not relative paths **. please. ** All must be absolute passes to work. ** **

For the absolute path of the python command, it is better to check the information of the provider of the rental server. About ConoHa Wing I use here Please refer to the. image.png

Japanese characters are garbled with Matplotlib, but fonts cannot be installed

** On a shared server, operations that involve sudo privileges should be prohibited (at least my environment was NG). Therefore, it was troublesome to deal with the phenomenon that Japanese characters were garbled with Matplotlib. ** **

This could be dealt with by importing japanize_matplotlib. For how to use japanize_matplotlib, I referred to the following article.

-[Super easy] How to make matplotlib Japanese notation correspond in just 2 steps

Another point to keep in mind. ** You can use the pip install command, but you must run it with user privileges **. So pip install [module name you want to install] **--user ** And, let's add --user.

It's hard to code on a rental server

Since it is on a rental server, I can not put in a nice editor,

  1. Upload the locally created code to the rental server and make fine adjustments on the server with unfamiliar vi
  2. If you want to add a new function, download the code from the rental server, edit it locally, and go back to 1.

I was doing very inefficient work.

If you can confirm that it works to some extent, use ** git. .. .. ** ** I haven't had much experience in uploading to the production environment so far, and I didn't understand the value of git, but I will change my mind from today.

The splendor of making "loved BI"

  1. Some personalized reports are out of reach with Google Analytics and Twitter Analytics. As a result, blog love deepens
  2. A good practice for data processing and analysis

It's all good. Speaking of disadvantages, I'm worried about "loved BI" and ** I can't get a job **. ..

I think it goes without saying about 2., so I will supplement only about 1. Regarding 1., the specific merit I think is as follows.

-** Accurate tabulation by page ** --In the case of tabulation by page title, if the page title is changed in the middle, it will be regarded as another page. On the other hand, if the URL of the page is different, it may be regarded as a different page even though it is the same page (occurs when following the related link). --I was able to solve this problem by getting information from the Google Analytics API and identifying it myself. -** You can compose a report based on the KGI you want to watch ** ――The default report of Google Analytics consists of PV (page views), the number of users, and the number of sessions, but since I used KGI as the blog browsing time, it was difficult to confirm the information I wanted to see. ――The Google Analytics API provides various information including browsing time, and we were able to solve this problem by acquiring and aggregating the necessary information. The following is a reference for the details of the information that can be obtained with the Google Analytics API. First of all, I think it is better to google appropriately and get an overview before referring to it. - Dimensions & Metrics Explorer -** You can analyze by associating multiple sources such as Twitter and Google Analytics ** ――Since attracting customers to my blog depends on Twitter, it is very important how the announcement on Twitter affects it. ――By linking the data of Twitter API and the data of Google Analytics, you should be able to watch the influence of Tweet including the link of the corresponding page on blog attracting customers (currently under development). -** AB test results can be monitored in real time ** ――Sometimes you want to do an AB test using Twitter. Twitter Analytics doesn't support such customizations, and even if you don't create a "loved BI", you'll have to analyze it yourself. ――What if the preliminary figures for the AB test were posted on "Beloved BI"? Love will deepen (currently under development)

Yes, it's wonderful.

Who are you?

It should be summarized briefly, but it has become longer than I expected. .. I think that those who have read this far are those who have been a little interested in the article, so I will briefly introduce myself.

I am a data scientist apprentice at a Japanese legacy company (about 1.5 years of analysis history). I felt a sense of crisis that it wouldn't grow if it was just my own project, so I started to analyze it using blogs and Twitter.

Finally, I would like to conclude this article by introducing a post that seems to be a self-introduction. Thank you for reading to the end despite the long text.

-I changed my job from a strategic consultant to a data scientist (article a year ago) -What I learned against the dissolution of the data analysis organization -Beloved BI (planned)

Huh. I feel like I've written an article that doesn't seem to be in demand. ..

Recommended Posts