GA is great but ever wondered how to get your stats for content created on a certain date or within a data range? Python to the rescue!
If you manage any social media channels, especially if it’s not your personal but your employer’s official account, sometimes, you might struggle to come up with new content. That’s totally normal, it can be really demanding to publish engaging stuff on a daily basis.
Towards the end of the year what you can do is to review your website’s content and see which articles, resources, and pages have been the most popular and simply re-share the top 10 published content.
OK, but how do I know how my content is performing?
Well, you need to have some kind of analytical tool connected to your website, probably it will be Google Analytics (GA) and then you can explore your stats. But there is just one tiny problem. Out of the box, you cannot filter your content by post_date. There are a few solutions out there, for example, to use Google’s Tag Manager to add in post_date as a custom dimension as outlined in this blog post, but based on your setup this might not be possible. Today we are going to use Python to overcome this issue, which might not be the easiest solution, but hey, if you really want to get serious about your data, you will eventually want to use the GA API and Python’s excellent data wrangling and analysis libraries.
For this tutorial, you will also need access to your website’s CMS database, in my case, a WordPress SQL database, and install a few Python packages like:
conda install -c conda-forge python-dotenv #OPTIONAL conda install -c conda-forge pandas #PROBS YOU ALREADY HAVE THIS conda install -c conda-forge google-api-python-client conda install -c conda-forge oauth2client conda install -c condo-forge ipython-sql #FOR IPYTHON MAGIC conda install -c anaconda sqlalchemy #PYTHON SQL TOOLKIT ## Plus you need to install the DBAPI driver for whatever connection you will use. Here is a nice tutorial.
Also to follow along, you would want to use Jupyter Notebook as some of the syntaxes will be specific to it.
In this post, we will learn about pandas’ data structures/objects. Pandas provide two type of data structures:- ### Pandas Series Pandas Series is a one dimensional indexed data, which can hold datatypes like integer, string, boolean, float...
Pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the Python programming language.
In this tutorial, you’re going to learn a variety of Python tricks that you can use to write your Python code in a more readable and efficient way like a pro.
Today you're going to learn how to use Python programming in a way that can ultimately save a lot of space on your drive by removing all the duplicates. We gonna use Python OS remove( ) method to remove the duplicates on our drive. Well, that's simple you just call remove ( ) with a parameter of the name of the file you wanna remove done.
In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.