Instagram’s new business analytics tools

Instagram popup

Instagram for business, finally!?

I’ve taking a bit of a hiatus from Instagram to focus on other platforms like Snapchat and Twitter (Which both have their own bit of intrigue and unique audiences.). After posting a photo recently the Instagram the following popped up asking if I’d like to switch to a Instagram Business Profile .

If you’ve ever looked at into Facebook advertising what you get here is an even more condensed version. In fact your Facebook Page for your business and your Instagram profile are linked together. Yes Facebook and Instagram are pay to play now if you’re not already famous.


You can also find the business profile in your settings. Next you choose an existing Facebook page and you’re all good. You can also turn off the business profile at any time. @ncrmro being my handle (I’m very active) and J-Tronics this website (and my consulting business). I choose ncrmro for now since you can switch it.

 


img_1445

The Metrics

The Instagram blog post speaks on how difficult business analytics typically are (Anyone who’s ever used Google Analytics can attest to that) be. The analytics tools are quite simple, and focus on three things.

  • Impression
  • Reach
  • Engagement

 

 


Your new profile and general metrics

Once you land on your new profile it will pull the contact info from your page and users can click the contact button to reach you through email, phone or directions (mine pulls up to Houston, TX not my home address.) At the time of writing I had my info here but will probably remove it for the time being.


Metrics continued

 

Here are some cool metrics including, gender, age, and geographies.


Ok, great. How much does it cost.

Their two options, call or visit a business or visit a website. Prices are pretty darn close and Facebook has set 5 dollars as a baseline.

Setting up Payment

You can choose to connect a card, or use Paypal. I’ve opted forPaypal


Setting up a campaign

Let’s pretend for a moment I’m actually interested in promoting Attibassi Cafe’s bagged espresso beans.

Creating a custom Audience

Attibassi Cafe based in Italy would like to increase their california market of youngish caffeine consumers. Here we can really fine tune the audience including things like age, gender, topics and geography(country, state, or city)

Develop with Django in OS X using Pycharm

django logo positive

Django is a framework for “Perfectionists with deadlines”. This is a throwback to the DRY principle eg Do not repeat yourself. Pretty much most website consist of the same things. Frameworks take all those common tasks and makes is so you don’t have to reinvent the wheel every time you start a new project. We’re going to use Pycharm, which comes in two versions professional edition or the free community version. We’ll be using Homebrew to install python3 and Virtualenv to keep our dependencies separate for different projects.

We’ll set up Pycharm to

  • Automatically activate your Virtualenv session in the terminal and project
  • Set the python environment variable.
  • Run tests and provide coverage
  • Browse the database
  • Run Prospector to lint and check for other code errors.

Setting up OS X dependencies

Install python3

Upgrade pip

Create the .virtualenv directory in your home folder. I had a lot of confusion about where to put .virtualenv  folder initially but this appears to the be the proper place to store your virtualenv’s.

Install virtualenv


Configuring Virtualenv

You can use Pycharm’s Project Interpreter in the project settings to create a virtualenv or select an existing one which we will discuss later or use the following command replacing project-name with your project’s name.

Then to activate the virtualenv we just run

You’ll now see you (project-name) at the beginning of the terminal prompt.


Installing Django and creating a project

We can now install Django

We can start a Django project like so


Django-Edge project skeleton

A more complete place to start is Django-Edge “A Django project skeleton that is modern and cutting edge.”

  • Ready Bootstrap-themed pages
  • User Registration/Sign up
  • Better Security with 12-Factor recommendations
  • Separate settings and pip requirements for production and development environments
  • Logging/Debugging Helpers
  • Works on Python 2.7 or 3.4

We can use the Django-Edge template like so

The directory will look like this.


Installing Django-Edge dependencies

We can install dev dependencies with

This will load all the requirements from the /requirements/base.txt and the /requirements/development.txt .

To load the production dependencies (We still should test production locally) we run

The project settings by default uses the ./src/project-name/settings/development  settings by default which inherits settings from ./src/project-name/settings/base that both production and development using this nifty line from .base import *  at the beginning of each settings file.

The line below for example in the development file adds the django_toolbar app the the installed app array found in the base settings file.


Using Environment Variables in local.env

The Django settings files loads the database information from and other environment variables in the file found at  ./src/project-name/settings/local.env. Django-Edge includes a local.sample.env we can use by copying and renaming it to local.env


Starting the web server

To start the project just run

To tell Django to start the server in production we can use the production settings.

When running other commands such under production settings we can use a temporary environment variable.


Making Migrations

To create the development database and create all the database settings we need to migrate the database. Makemigrations will create a starting point and history of our database. Then migrate will apply those migrations to the database.


Time saving Pycharm settings

Some of these features may only be available in the Professional version which can also be unlocked with a university email account.


Configuring built in Django Support

pycharm-django-settings
Setting Django settings in Pycharm

Creating or setting Virtualenv and installing Pip dependencies

Create a virtual environment in Pycharm note to use the python3 base interpreter we installed using homebrew.

creating virtual enviorment in pycharm
Creating virtual environment in Pycharm

If you inspect  the project files and don’t have dependencies installed you’ll get a nice pop up asking if you’d like to install dependencies.

Install Django dependencies in pycharm
Install Django dependencies in pycharm

Automatically starting Web Server

We can set Pycharm to automatically start the development server when you open the project. The Run/Debug settings are found under the arrow drop down at the top right of the IDE.

Pycharm edit configurations
Pycharm edit configurations

 

Pycharm run Django development server
Pycharm run Django development server

 

Start Django server on Pycharm project opening
Start Django server on Pycharm project opening

Have Pycharm terminal auto activate the Virtualenv and change to project dir

Create the following file called .pycharm-bash

Load custom bash in Pycharm terminal
Load custom bash in Pycharm terminal

Using Pycharms database viewer.

Make sure the database plugin is working.

 

Pycharm plugins enabling django database support
Pycharm plugins enabling Django database support

 

Now you can browse the database.

Pycharm database
Pycharm database

Connecting to a Postgres Database

To connect to a Postgres database open data sources and drivers from the wrench button above the database view. And go ahead an click download to get the postgres drivers.

Pycharm connecting to postgres database
Pycharm connecting to postgres database

The click the arrow at the top left of the data sources and drivers window and add your database settings and apply

connecting pycharm to postgres database
connecting pycharm to postgres database

 

After you set up the correct log in info you should test the connection and get the following

Pycharm postgrest success connection
Pycharm postgrest success connection

 


Pycharm Testing & Coverage

Django-Edge comes with a few tests, I’ve added a pull request that should push coverage up to 96% and run a few extra tests. Allow you to develop much quicker without having to manually check everything works every single time.

pycharm configure testing
pycharm configure testing

As you can see the green bars in the gutter next to the code show which lines are covered giving you key insights into where you should be adding more tests.

pycharm run tests & coverage
Pycharm run tests & coverage

Debugging the front end with the Javascript Debugger.

Make sure to have the Jetbrains IDE Support chrome extention plugin enabled. Then enable/install the Pycharm Live Edit plugin

 

installing pycharm live edit
installing pycharm live edit

 

While your at it change the Live edit update time

pycharm live edit update time
pycharm live edit update time

Then enable it in your run Develop

enable live edit javascript debugger pycharm
enable live edit javascript debugger pycharm

 


Installing Prospector to check for and lint code

 

Then we will open the settings and go to external tools. Set it up as follows. We will use two pycharm macros one that will get the virtualenv interpreter of the current project to find prospector. And the other to set prospector run in the project root folder.

pycharm prospector external tools
pycharm prospector external tools

We should also create the .prospector.yaml for some extra configuration. These are very strict settings requiring docstring, disables the conflicting D203 or add a line before docstring which clashes with no lines before docstring.

 

Configuring OS X for WordPress development

Wordpress Logo Horizontal CMYK

This post will cover setting up OS X for WordPress development. We go the extra mile to set up all our packages in OS X using Homebrew this include

  • PHP
  • Nginx (Better under load than Apache the default web server in OS X and for WordPress, Apache vs Nginx here)
  • MySQL
  • Unix Sockets for
  • dnsmasq so we can use real URL’s like mysite.domain and not localhost:8080.

 

While apache might be easier to set up we will use Nginx so you can become familiar with it in a development environment.

Install Xcode and the command line tools

Xcode is available at the app store here, you will need to agree to the license. Once it’s finished open up a terminal and enter the following to install the Xcode command line tools.

Press the enter key to read the Xcode license, keep hitting space till you reach the bottom and then type agree.

Installing Homebrew

We will first need to install homebrew a package manager that will download, manage and upgrade our dependencies (Nginx, MySQL, Php and Dnsmasq) while keeping them separate from any packages included in macOS.

To install copy and paste this command into your terminal. Do not run it as root. You should see Installation successful! Once finished

Brew also asks us to run doctor to make sure everything works.

If everything is ok brew should return the following.

It’s a good idea to run brew update before installing anything, This will make sure you have the latest version of Homebrew and all the newest formulae from the main repository.

All homebrew packages get installed to the Cellar in /usr/local/Cellar/ with the name of the package and the version as the folder name. These folders are then system linked to /usr/local/opt so the latest version is available in a folder named after the package. An example would be the nginx package which we will be installing next.

/usr/local/Cellar/nginx/1.10.1/

/usr/local/opt/nginx/


Installing Nginx

If you haven’t run brew update earlier or recently do it now. Now we will install Nginx

Once that finishes you should see the following. This means Nginx is serving files from /usr/local/var/www and listening on localhost:8080. Localhost simply means “this computer” and will always point to the computer your using, rather than your website being served from a domain such a J-Tronics.co or and IP address such as 192.168.1.100 its found a localhost:8080 since Nginx runs on 8080 by default. Later down we will change this to something more ppleasant such mysite.dev.

As homebrew mentions above to make Nginx start a login we’ll issue the following command.

Now we can open our browser and navigate to localhost:8080 and the following will show if everything is working.

nginx index html
nginx index html

Installing PHP

Before we configure Nginx we need to install Php. The following command will install PHP version 7.0 with MySQL, PHP-FPM modules and won’t include the Apache module.

Then set PHP to start at login.

One last change is we will change PHP-FPM to listen on a unix socket instead of a TCP socket. These means if Nginx needs to make a PHP request and on they are on the same computer it will skip the IP/Network stack. This ends up being much faster.

The file is located below. We use nano to edit it. At the bottom of the file add the line below

At the bottom of this file add the following.

Then we check that PHP-FPM is  correctly configured

Which should return something similar

Restart PHP

 Installing MySQL

And set it to start a login and now.

Secure your MySQL installation by running the following command.

The first question will be if you’d like to use the validate password plugin press no.

Next it will ask you to set a root password, your password won’t ben shown when you type.

Remove the anonymous user and tables

Next set root access to only  be allowed on localhost

Remove the test database

Reload the table privileges

All done!

Rather than deal with MySQL commands we can instead use a nifty tool called Sequal Pro. Go ahead and download it. Click on the Socket tab, settings are as follows with your password of course. Before you click connect make sure to add this connection to your favorites for future reference.

sequel pro login
sequel pro login

Then add a user called wp-user, add a password and click apply.

sequel pro add user
sequel pro add user

Then click the “Choose Database” drop down and click add new database and call it WordPress. Once your done with that open up the Users page again and click Schema Privileges and click the WordPress table on the left and shift click and select all the privileges and click the arrow to move them over to the Granted Privileges tab.

sequel pro add privalges
sequel pro add privileges

After that we’re good to go as far as database go.


Configuring Nginx

Next up we will configure Nginx

Run the following command to create the sites available and sites-enabled which is how Nginx on Linux Ubuntu is set up. First we will setup the WordPress directory in your user folder. The ~ (tilde) is a shortcut for the current user’s folder.

Create the site configurations

Edit the nginx.conf file with nano or your favorite text editor such as text wrangler.

Paste the following into nginx.conf. This will create a minimum conf file and will include all other config files in the sites-enabled that end with .dev thanks to the user of a wildcard *.

Then either create the file with nano or a text editor.

And paste the following into wordpress.dev be sure to replace my site with your choice of domain and change the root and fastcgi user paths to your username.

Restart Nginx to apply the changes.


Adding WordPress files

wordpress setup config
wordpress setup config

Visit the WordPress.org site and download the software. Unzip it and copy the WordPress folder from your downloads folder to the Nginx site root we created earlier. Once your done visit your browser at localhost:8080 and you should see the WordPress setup config.

Where not done yet, if your working on a single user site or don’t care for pretty domains you can stop here.


Using Dnsmasq and Nginx for pretty domains

Not only is typing localhost into the browser not very nice, but WordPress multi site won’t configure correctly with ports applied. We will instead use pretty domains that way we can type something like mysite.dev into the browser instead of localhost.

Add it to start a login

The configuration file  dnsmasq.conf is fount under /usr/local/etc/.

Inside we put the following line:

This will redirect all *.dev sites to the local IP eg 127.0.0.1

Then open your OS X system settings and click on network, click on advanced. Click on the DNS settings, click the + and add 127.0.0.1 and drag it to the top if its not already. Your settings should look as follows.

os x dns settings
os x dns settings

Now if we attempt to ping any address ending in .dev should return 127.0.0.1

 

Forwarding port 80 to 8080

The first file we need to add is an anchor file. This defines the ports we want to forward. Create the file in /etc/pf.anchors/dev  and add the following.



Create a pfctl config file /etc/pf-dev.conf and add the following.

Start the config file.

Forward ports at startup

Create the LaunchDaemons  /Library/LaunchDaemons/com.apple.pfctl-dev.plist file with the following contents

Add the file to startup using the following command:


Nginx.conf Part 2 Pretty Domains

Go ahead and open you wordpress.dev conifg file again.

We’ll go ahead and change the port if you run different applications, I’ve changed it to 8085. Also add the new pretty domains of your choice, add a space for multiple domains.

Restart Nginx to apply the changes.

Finish WordPress Setup Config

Go ahead and open your browser and go to your newly configured mydomain.dev, click on your language of choice, change the username to wp-user and add your password

wordpress setup config database
wordpress setup config database

Once your done  you’ll  be asked to create a user, then sign in!


WordPress Multisite

Add the following to your wp-config.php above where it says /* That's all, stop editing! Happy blogging. */.

Then go to your WordPress admin and under tools click on network setup. You can choose sub domains or sub directories. Don’t worry we will use a plugin so site1.mysite.dev will show up as site1.dev

wordpress create network multisite
wordpress create network multisite

Then the next screen will tell you to add the following to your wp-config.php above the previous multi site settings.


Mapping are custom domains using WordPress MU Mapping

Download the plugin. Then copy sunrise.php to /Users/user/www/wordpress/wp-content/sunrise.php from the WordPress MU Mapping plugin folder.

Then add to  define( 'SUNRISE', 'on' ); your wp-config.php

Then add your computers IP address.

 

wordpress domain mapping configuration
wordpress domain mapping configuration

If you enjoyed this article read more at our WordPress Section. We also have a subscription box at the footer.

WordPress “Press This”: A Complete Guide

Wordpress Hosting Logo

WordPress Press This Feature

The WP Press This feature, allows you to share clip text, images, video, posts from any website such as tweet from twitter, facebook or even other WordPress blogs and quickly give your own commentary. It’s a pretty simple thing to set up. Originally it came in the form of a now deprecated plugin. Instead it is automatically including in the WP versions higher than 4.2.0.

First go to your wordpress admin page. Then put your mouse over tools or click on it and then the available tools page should show then click on available tools.  The Press This section will be the first section show. New just drag either the bookmarklet button or the clipboard icon to your bookmarks bar at the top of your web browser. If your on mobile you can user the direct link button by clicking the open press this button which will open a new page which you should bookmark.

Now any time your on a website, image, video, or post just click the press this button which will ask you to log in if you aren’t already logged in. You can also instead highlight or select the text you would like to share and then click the bookmarklet and a new page will pop up with the selected text in quote form.

You can also choose to edit the post in the admin page allowing for publishing at a later date or more fine tuning of tags categories or SEO needs. Once done publish the post and it will automatically give credit to the original post and author. You can also add new images using the “Add Media” button.

wordpress press this menu
If you enjoyed this please check out other articles on J-Tronics.co such as are wordpress section, leave a comment or subscribe to our newsletter bellow.

[mc4wp_form id=”629″]

Filter WordPress Admin Traffic in Google Analytics

Filter Wordpress Admin Traffic in Google Analytics

Ever notice a bump on you in wordpress traffic after making modifications to your site. It happens to everyone when making large changes to your site. You will need to already have created and configured your Google Analytics. In this post we will discuss how to filter WordPress admin traffic in Google Analytics. The most preferred way is by setting a cookie. You can go ahead and skip to the bottom if that’s all you need.

Google analytics allows you to filter traffic in a few ways.

  • IP address
  • By url
  • Excluding traffic by Cookie content.

Finding the Filters

First find the filters page after clicking the Admin tab at the top after selecting your website from the home page. Then under the VIEW tab on the right find the filters button.

google analytics admin page
Google Analytics admin page

Filter by IP Address

A quick google search of what’s my IP address will tell you your current address. Usually your IP address is only static on business level internet providers. Mine hasn’t changed in a long time with my ISP so for good measure I add it anyway.

Google Analytics filter by IP address
Google Analytics filter by IP address

Next up we will set up filters based on portions or entire URL’s we specifically want to ignore. This includes any URL’s with wp-admin, or preview=true.

Filtering by URL

Let’s go ahead and add the Post Preview Filter. Verify the filter to see which pages will be filtered.

Google Analytics Filter WordPress Preview Posts
Google Analytics Filter WordPress Preview Posts

Then we will go ahead and add the admin page for good measure.

Google Analytics filter WordPress Admin
Google Analytics filter WordPress Admin

Filter by cookie

Finally the preferred way is to create a simple html document that you can access on all your devices that will save a cookie with a variable that we can then use to filter out all your devices. Create filter-website-name-traffic.html, edit your Google account number where UA-12345678-9 is, and then upload it to your wordpress directory. Note the copy button on the toolbar when you mouse over

Filter traffic by cookie
Filter traffic by cookie

Add the filter. Then on each of your devices (desktop, laptop, phone, tablet etc) browse your website.com/filter-traffic.html and it will automcatially save the cookie for future reference.

 

Check out more amazing content on our optimizing WordPress page.

Or subscribe to our newsletter for more great posts!

[mc4wp_form id=”629″]

 

We love comments! Leave questions or comments below.