Google Analytics v4 API + Node.js Starter Example

Google has lots of good documentation on starting out with Google APIs (which is used for Google Analytics) for certain languages like Python, Java, and C#, but completely sketchy for Node.js. Googling there are many examples but most are for v3. And the implementations get confusing if you aren’t familiar with oAuth or JSON Web Tokens.

Here is a really simplified chunk of starter code for pulling the number of Goal 2 completions by source/medium, ordered in descending order. The assumption is that you have already set up the service account and downloaded the JSON file with the private key.

var prettyjson = require('prettyjson'); // Un-uglify JSON output
var {google} = require('googleapis');
var key = require('<SERVICE_ACCOUNT_JSON_FILE>'); // Downloaded JSON file

var viewID = '<VIEW_ID>'; // Google Analytics view ID
var analytics = google.analyticsreporting('v4'); // Used for pulling report
var jwtClient = new google.auth.JWT(key.client_email, // For authenticating and permissions
                                    null,
                                    key.private_key,
                                    ['https://www.googleapis.com/auth/analytics.readonly'],
                                    null);

jwtClient.authorize(function (err, tokens) {
  if (err) {
    console.log('Reeeeejected');
    console.log(err);
    return;
  } else {
    console.log('Yup, we got authorized!');
  }
});

// Set up what we data we want to pull from Google Analytics
metrics_columns = [{
  expression: 'ga:goal2Completions'
}];

dimensions_rows = [{
  name: 'ga:sourceMedium'
}];

date_filters = [{
  startDate: 'today',
  endDate: 'today',
}];

sort = [{
  fieldName: 'ga:goal2Completions',
  sortOrder: "DESCENDING"
}];

var req = {
  reportRequests: [{
    viewId: viewID,
    dateRanges: date_filters,
    metrics: metrics_columns,
    dimensions: dimensions_rows,
    orderBys: sort
  }],
};

// Options for prettifying JSON output
var pretty_json_options = {
  noColor: false
};

// Pull report and output the data
analytics.reports.batchGet({
    auth: jwtClient,
    resource: req
  },
  function (err, response) {
    if (err) {
      console.log('Failed to get Report');
      console.log(err);
      return;
    }
    // response.data is where the good stuff is located
    console.log('Success - got something back from the Googlez');
    console.log(prettyjson.render(response.data, pretty_json_options));
  }
);

Load Google Drive CSV into Pandas DataFrame for Google Colaboratory

Researching platforms for running common machine learning algorithms on advertising keyword data, I found Google Colaboratory. It’s essentially a machine learning environment with accessible Jupyter notebooks…but without all the headaches of setting up your own dev environment. Mainly for educational and research purposes, I wanted to try it out with a small data set.

Of course, it’s never quite that easy. Out the door I needed to figure out how to load up a train.csv and test.csv stored in Google Drive into the Jupyter notebook, and more specifically a Pandas DataFrame. There are instructions but they are intermingled with other things I didn’t care about.

Here is a quick rundown of Juypter code to load existing CSV files stored in Google Drive into Google Colab.

import tensorflow as tf
tf.test.gpu_device_name()

This loads up TensorFlow and displays what GPU is being used. If it returns nothing, go to Runtime -> Change Runtime Type, change Hardware accelerator to GPU and hit save. Then re-run the code above. The result should be:

'/device:GPU:0'

If so, you are ready to move on.

!pip install -U -q PyDrive

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

# 1. Authenticate and create the PyDrive client.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

The above code installs PyDrive which will be used to access Google Drive and kicks off the process to authorize the notebook running in the Google Colaboratory environment to touch your files. When it runs, you will be presented with a link to click on, which asks to verify Google Colab can have access to Google Drive and unique key. Enter the key back in the notebook.

file_list = drive.ListFile({'q': "'<FOLDER ID>' in parents and trashed=false"}).GetList()
for file1 in file_list:
  print('title: %s, id: %s' % (file1['title'], file1['id']))

This code assumes your CSV files are in a folder. It will print out the files in a folder and their unique identifiers which will be used below. Replace <FOLDER ID> with the long string of numbers and letters in the URL of the folder in Google Drive. If the files are located at the top level of Google Drive, replace <FOLDER ID> with ‘root’. The output should look like:

title: train.csv, id: <TRAIN_FILE_ID>
title: test.csv, id: <TEST_FILE_ID>

The output will be a list of files in the specified folder and their ids.

train_downloaded = drive.CreateFile({'id': '<TRAIN_FILE_ID>'})
train_downloaded.GetContentFile('train.csv')
test_downloaded = drive.CreateFile({'id': '<TEST_FILE_ID>'})
test_downloaded.GetContentFile('test.csv')  

Now the files get pulled into Google Colab. GetContentFile saves the files in the local environment and sets the names of the files.

import pandas as pd
import numpy as np
df_train = pd.read_csv('train.csv')
df_train

Now comes the easy part. Since the files have been saved to the local environment, load up a saved file, by its filename, into a DataFrame and print out a few lines to verify.

df_test = pd.read_csv('test.csv')
df_test

Repeat as needed.


FYI, I’ve just started a podcast about the relationship and connections between marketing, technology, business, consumers and generally the world around us. If you are interested, click on one of the links below.

Subscribe: Apple Podcasts / Overcast / Spotify / Stitcher

WordPress Checklist – 150+ Things To Do Before Launch

WordPress Checklist - 150 things to do before Launch

Ok, here is a WordPress checklist for you to go through before launching a brand new website. I started with a Website Checklist which was more general. This checklist is obviously a bit more focused. Like the Website Checklist, the WordPress Checklist will evolve over time as well.

There aren’t any specific WordPress plugins mentioned except in a couple places. There are lots of others who do a fantastic job reviewing plugins, so do some Googling.

Of course this checklist doesn’t cover everything related to creating a WordPress site, because then I’d have to write a book. I didn’t go in-depth into topics like design and SEO because they deserve their own checklists.

The most recent version is on GitHub.


Setup

Best Practices

  • Web Server Configuration – Point to root WordPress folder. URL should not contain 'WordPress' anywhere.
  • Database Table Prefix – Change from wp_.
  • Database Connection – Change to connect to dev database.
  • Plugins – Remove unused plugins.
  • Themes – Remove unused themes.
  • Version – Remove generator meta in header.
  • Admin Account – Rename from admin.
  • Security Keys & Salts – Change from default.
  • Admin URL – Change from default.
  • Default Content – Remove default posts, comments, and pages.
  • Default Date / Time – Set in Settings > General.
  • Default Blog Category – Change from uncategorized.
  • Media Settings – Set to month and year or appropriate file path.
  • Permalinks – Set to post name or appropriate URL structure.
  • Site Title – Set to proper website title.
  • Site Tag – Set to proper website tagline.
  • Admin Email – Update to someone on web development team. This is not the same as admin user account.
  • Memory Limit – Set memory limit to maximum allowed by server or web host.
  • Auto Save – Set number of seconds between auto-saves.
  • Multisite – Enable if needed.
  • Debug Flag– Enable during development.
  • Cache – Disable during development.
  • Search Engine Visibility – Disable development environment from being crawled by seach engines.
  • Sample Config File – Remove wp-config-sample.php.
  • Version Control – Set up repository to store and track files and changes.

Theme Design

Best Practices

  • Login Page – Update with site brand.
  • Underlined Links – Underline to help with usability and accessibility.
  • Visited vs Unvisited Link Colors – Use different colors for usability.
  • Hover / Focus / Active Links – Visually distingush when in hover, focus, or active states.
  • Color Contrast – Contrast ratio should be minimum 4.5:1 for WCAG 2.0 AA compliance.
  • Form Placeholder Text – Set placeholder attribute in input elements.
  • Descriptive Buttons – Use pattern Verb Noun, like Upload File, instead of Ok or Submit.

Coding

Best Practices

  • Core Files – Never modify any WordPress core files.
  • Database Queries – Don't use mysqli_query(), instead use $wpdb object or WP_Query.
  • 'DISTINCT', 'GROUPBY' – Avoid cross-table queries and any other operations which create temporary tables.
  • Query Result Limits – Add maximum number of results returned to prevent killing database.
  • Indexes – Verify indexes are used in queries by running EXPLAIN statement.
  • Address Bar – Only show encrypted session values in address bar.

Plugins

  • Mail – Use wp_mail() instead of PHP mail() function.
  • Clean Inputs / Outputs – Sanitize/escape all inputs and outputs to prevent Cross-Site Scripting (XSS) problems.
  • Nonces – Protect against Cross-Site Request Forgery (CSRF) when expecting user submitted data.
  • Data Validation – Use JavaScript, built-in PHP functions, core WordPress functions, and/or custom functions to validate inputs before processing.
  • Cache DOM Queries – Cache jQuery selectors for re-use on page.
  • Event Delegation – Reduce individual element event handling by using event delegation instead.
  • Deactivate / Uninstall Hooks – Implement to cleanup data.
  • Prefix – Add plugin name abbreviation as prefix to variables, functions, and classes.
  • Folder Structure – Separate into includes, admin, and public folders.
  • Roles and Rights – Verify authentication and authorization of user when plugin called.
  • Settings / Options API – Use to build admin pages.

Themes

  • Child Themes – Create child theme if modifiying existing theme allows for child themes and changes are not extensive.
  • File Structure – Separate into include, asset, and template parts folders.
  • Template Tags – Instead of hardcoding, use template tags and conditional tags as much as possible.
  • Enqueue Stylesheets – Use wp_enqueue_style and template tags for directory paths instead of hardcoding links to CSS files.
  • Enqueue JavaScript – Use wp_enqueue_scripts and template tags for directory paths instead of hardcoding links to JavaScript files.
  • File Naming – Use standard WordPress naming hierarchy.
  • Theme Unit Test – Use WordPress Theme Unit Test to visually inspect and test theme and test using Theme Check plugin even though theme will not be submitted to WordPress theme directory.
  • Screenshot – Create screenshot with look and feel of theme.
  • Jetpack Infinite Scroll – Support if needed.
  • '$content_width' – Set.

Theme HTML

Best Practices

  • HTML5 Semantic Elements – Use HTML5 semantic elements appropriately.
  • Error pages – Create 404 page and 5xx error pages. 5xx error pages can be handled by web server.
  • AMP / Instant Articles – Generate stripped down HTML for Google and Facebook.
  • Labels / Inputs – Connect labels to inputs using for attribute in labels.

Head

  • Doctype – Set Doctype to HTML5 and put at the top of header.
  • Charset – Set to UTF-8.
  • X-UA-Compatible – Set for backwards IE compatibility.
  • Viewport – Set viewport.
  • Favicons – Set favicon file location.
  • Apple Touch & Android Icons – Set Apple touch & Android icons.
  • Canonical – Set rel=“canonical”.
  • Language tag – Set language tag.
  • Conditional comments – Set conditional comments for IE.
  • RSS feed – Set RSS URL or remove.
  • Smart App Banner – Set app-id and app-argument if app available from app store.
  • Facebook Open Graph – Set and link to images.
  • Twitter Card – Set and link to images.

HTML Testing

  • W3C Compliance – Run pages through W3C validation tools.
  • Desktop Browsers – Test pages on current (and back one version) of current desktop browsers.
  • Mobile Browsers – Test pages on current (and back on version) current mobile browsers.
  • Link Checker – Run pages through broken link checkers.
  • Adblockers Test – Verify adblockers do not break pages.

Theme Fonts

Best Practices

  • Webfont Formats – Convert fonts to WOFF, WOFF2 and TTF file formats.
  • Fall-back Typefaces – List 2 or more in case desired fonts not available.
  • Service Configuration – Set live domain and development IPs to be white-listed with hosted font services.

Theme CSS

Best Practices

  • Preprocessors – Remove links to intermediary preprocessor files.
  • Breakpoints – Check content, flow, and UX work as intended at different breakpoints.
  • CSS Print – Set print stylesheet for each page.
  • Unique ID – Use unique IDs per page.
  • Reset CSS – Use CSS reset stylesheet.
  • JavaScript Prefix – Name classes or IDs with js- when modified by JavaScript and not by CSS files.
  • Inline / Embedded CSS – Remove or minimize embedded or inline CSS.
  • Vendor Prefixes – Use CSS vendor prefixes depending on required browser support compatibility.
  • Stylesheet Layout – Order of properties display > positioning > box model > colors and typography > other.
  • Media Queries – Place at bottom of stylesheet.
  • Magic Numbers – Avoid.
  • Main Stylesheet Header – Include theme name, author, description, version, license, license URI, and text domain.
  • Sticky Posts – Set to be visually distinguishable.

Performance

  • Concatenation – Concatenate CSS files.
  • Minification – Minify CSS files.
  • Non-blocking – Verify CSS files are non-blocking in theme template.
  • Unused CSS – Cleanup CSS.

CSS Testing

  • CSS Validator – Run stylesheets through CSS validators.

Theme Images / Videos

Best Practices

  • Placeholder Images – Replace with real images.
  • Stock Images – Replace stock watermarked images replaced with licensed versions.
  • Optimization – Optimize for needed browsers and devices.
  • Retina – Use x2 or 3x images to support retina display.
  • Width and Height – Set <img> to have height and width, handle with CSS and media queries, or serve appropriate sizes for respective browsers and devices.
  • Alternative text – All <img> have an alternative text which describe the image visually.
  • Lazy loading – Load images on scroll or as needed.
  • Social Thumbnails: Generate Facebook/Twitter/LinkedIn thumbnails for all pages.
  • Responsive Video Players – Videos resize appropriately on different browsers and devices.
  • Video Controls – Show playblack, pause, and mute controls.
  • Logo – Set logo link to return visitor to homepage.

Theme JavaScript

Best Practices

  • jQuery Version– Do not add newer jQuery libraries if available.
  • '$' Shortcut – Use IIFE to create.
  • JavaScript Inline – Remove or minimize inline JavaScript.
  • Concatenation – Concatenate Javascript files.
  • Minification – Minify JavaScript files.
  • Non-blocking – Load JavaScript files asynchronously.
  • Modernizr – Use Modernizr or similar tool to test for specific browser features.
  • Footer Load – Place scripts in footer of page.
  • eval() – Never, ever use.

JavaScript testing

  • ESLint – Verify JavaScript with ESLint or similar tool.

Copy

Best Practices

  • Text – Replace all Lorem Ipsum with real copy.

Security

Best Practices

  • HTTPS – Use HTTPS.
  • HSTS – Set HTTP Strict Transport Security parameter on web server.
  • Password Reset – Set password rules and flow on all authentication pages like Registration, forgot password, change password.
  • Login Limits – Require ‘human’ verification after a defined number of failed tries.
  • System Information – Verify application, server, or database version or connection information not publicly viewable.
  • SSL – Verify certificate not expiring.
  • Exploit Scanner – Run plugin on site.

Performance

Best practices

  • Minified – Minimize HTML and enable gzip type compression on web server.
  • Lazy loading – Load images, scripts, and CSS files as needed, not on load.
  • Cookie size – Minimize size of cookies.
  • Content Delivery Network – Push CSS, JavaScript, fonts, and generated HTML to CDN.
  • HTTP Cache Headers – Set approriate parameters.
  • DNS Prefetching – Enable preload and/or dns-prefetch.
  • Mixed Content – Retrieve all files and assets via HTTPS.
  • Logging – Enabled tools and verify data passing to monitoring platforms.

SEO

Best Practices

  • Tag Manager – Set up and verify data passing to tools.
  • Analytics & Conversion – Google Analytics and similar tools installed,correctly configured, and registering data.
  • Exclude IPs – Remove office or home IPs from analytics and conversion tools.
  • Ad Pixels – Verify all ad pixels installed and registering.
  • Heatmaps: Verify installation, configuration, and data flow to third party tools.
  • A/B Tests: Verify installation, configuration, and data flow to third party tools.
  • Chat – Verify installation, configuration, and data flow to third party tool.
  • Sitemap XML – Install plugin to auto-generate and submit of site, image, and video XMLs to Google Webmaster Tools and similar tools
  • Google Webmaster Tools – Verify no errors noted by WMT or similar tools.
  • robots.txt – Verify robots.txt not blocking any pages.
  • Structured Data or Rich Snippets – Generate error-free structured data as needed.
  • Title – Use unique title tag used on each page.
  • Description – Set unique meta description on each page.
  • 301 Redirects – Return 301 for moved content
  • Redirections – Use Rewrite Rules Inspector plugin and check redirections.
  • Title Attribute – Set title attribute for all links.
  • Social Widgets – Connect social accounts and set up to show buttons / links in right places.

Legal

Best Practices

  • Privacy Policy – Create page and put link in footer.
  • Terms of Service – Create page and put link in footer.
  • GDPR Compliance – Show consent notice visible.
  • Copyright – Show in footer.

Pre-Launch

Best Practices

  • .htaccess – Set with appropriate settings.
  • Backups – Check backup and restore systems functional. Fully backup old site if one exists.
  • Versioning – Branch or tag production code in version control system.
  • Contact Forms – Set CAPTCHA functionality, required fields, validation, and verify information emailed or routed to CRM.
  • Newsletter Forms Check signup forms functionality and verify user information pushed to third-party tool.
  • Comments – Set moderation notices be sent to appropriate email addresses.
  • Search – Verify WordPress search or Google custom search traversing only necessary data, and returning correct results.
  • API Configuration – Set live domain to be witelisted with third party intergrations or SaaS tools.
  • Dev Domains – Verify database and assets not referencing dev, staging, or QA environments.
  • DNS – Verify proper set up.
  • Conversions & Funnels – Set analytics tools to collect visitor clickstream.
  • Payment System – Turn off test mode off and transactions work.
  • www / non-www – Set non-canonical to redirect to canonical and preserving URL.
  • Debug Mode – Disable in wp_config.php.
  • WordPress Address (URL) – Update to production URL in wp-config.php or Settings > General
  • Site Address (URL) – Update to production URL in wp-config.php or Settings > General
  • Plugin / Theme Auto-Updates – Update usernames, passwords, and API keys.
  • Gravatars – Set up user accounts with Gravatars if necessary.
  • Pagination – Verify 'next' and 'previous' display right content in respective categories.
  • Folder and File Permissions – Verify folder contents are not viewable and individual PHP files cannot be downloaded.
  • Upload Permissions – Verify images and attachments can be uploaded via backend and downloaded by non-logged in users.
  • Spam Protection – Enable Akismet plugin and delete old spam comments.
  • Post Revisions – Limit number of post revisions saved and delete post revisions generated during development.
  • Trash – Set number of days when deleted content can be removed from database.
  • Cache – Enable default WordPress caching or a third-party plugin.
  • Admin Email – Set to individual responsible for website post-launch.
  • Search Engine Visibility – Enable search engines to index site.

Post-Launch

Best Practices

  • Update Files – Set auto-update for core, themes, and plugins or create monthly or quarterly plan to test and roll out updates, especially if custom functionality was built for the website.
  • Documentation – Compile website, webhost, S/FTP, and social logins, along with expiration dates on third-party services, SSL, stock photography, etc, and share with appropriate individuals.
  • Error Logs – Check web server logs for PHP errors on a regularly scheduled basis.
  • Version Control – Transfer ownership of repository to client if necessary.

Website Checklist – 100 Things To Do Before Launch

Website Checklist - 100 Things To Do Before Launch

It’s weird to realize I’ve been designing websites for over 20 years. In that time, I’ve used always had a go-to website checklist to keep track of all the todos and tasks. I’m going to start tracking my website checklist and modifying it in public. The checklist will change over time, and it will be interesting to see how it evolves.

In the future, I’ll post some other checklists I’ve got related to designing, prototyping, coding, and testing. For now, this first website checklist is a final sanity check. Whatever website building process you use should have already addressed all the items on the checklist, but just in case, use it as the last step.

There is a mix of granularity. Some nitty-gritty, so thirty thousand foot level. A plan is to break down the high-level tasks into smaller individual tasks.

Remember, not every item applies to every site. Prune and append as needed.

Also, check out the WordPress Checklist.

You can find the most recent version on GitHub.


HTML

Best Practices

  • HTML5 Semantic Elements – Use HTML5 semantic elements appropriately.
  • Error pages – Create 404 page and 5xx error pages. 5xx error pages can be handled by web server.
  • Clean up comments – Remove unnecessary comments created when building site.
  • AMP / Instant Articles – Generate stripped down HTML for Google and Facebook.

Head

  • Doctype – Set Doctype to HTML5 and put at the top of all HTML pages.
  • Charset – Set to UTF-8.
  • X-UA-Compatible – Set for backwards IE compatibility.
  • Viewport – Set viewport.
  • Favicons – Set favicon file location.
  • Apple Touch & Android Icons – Set Apple touch & Android icons.
  • Canonical – Set rel=“canonical”.
  • Language tag – Set language tag.
  • Conditional comments – Set conditional comments for IE.
  • RSS feed – Set RSS URL.
  • Smart App Banner – Set app-id and app-argument.
  • Facebook Open Graph – Set and link to images.
  • Twitter Card – Set and link to images.

HTML Testing

  • W3C Compliance – Run pages through W3C validation tools.
  • Desktop Browsers – Test pages on current (and back one version) of current desktop browsers.
  • Mobile Browsers – Test pages on current (and back on version) current mobile browsers.
  • Link Checker – Run pages through broken link checkers.
  • Adblockers Test – Verify adblockers do not break pages.

Fonts

Best Practices

  • Webfont Formats – Convert fonts to WOFF, WOFF2 and TTF file formats.
  • Fall-back Typefaces – List 2 or more in case desired fonts not available.
  • Service Configuration – Set live domain to be white-listed with hosted font services.

CSS

Best Practices

  • Preprocessors – Remove links to intermediary preprocessor files.
  • Breakpoints – Check content, flow, and UX work as intended at different breakpoints.
  • CSS Print – Set print stylesheet for each page.
  • Unique ID – Use unique IDs per page.
  • Reset CSS – Use CSS reset stylesheet.
  • JavaScript Prefix – Name classes or IDs with js- when modified by JavaScript and not by CSS files.
  • Inline / Embedded CSS – Remove or minimize embedded or inline CSS.
  • Vendor Prefixes – Use CSS vendor prefixes depending on required browser support compatibility.

Performance

  • Concatenation – Concatenate CSS files.
  • Minification – Minify CSS files.
  • Non-blocking – Verify CSS files are non-blocking.
  • Unused CSS – Cleanup CSS.

CSS Testing

  • CSS Validator – Run stylesheets through CSS validators.

Images / Videos

Best Practices

  • Placeholder Images – Replace with real images.
  • Stock Images – Replace stock watermarked images replaced with licensed versions.
  • Optimization – Optimize for needed browsers and devices.
  • Retina – Use x2 or 3x images to support retina display.
  • Width and Height – Set <img> to have height and width, handle with CSS and media queries, or serve appropriate sizes for respective browsers and devices.
  • Alternative text – All <img> have an alternative text which describe the image visually.
  • Lazy loading – Load images on scroll or as needed.
  • Social Thumbnails: Generate Facebook/Twitter/LinkedIn thumbnails for all pages.
  • Flexible Video – Videos resize appropriately on different browsers and devices.
  • Video Controls – Show playblack, pause, and mute controls.

Copy

Best Practices

  • Text – Replace all Lorem Ipsum with real copy.

JavaScript

Best Practices

  • JavaScript Inline – Remove or minimize inline JavaScript.
  • Concatenation – Concatenate Javascript files.
  • Minification – Minify JavaScript files.
  • Non-blocking – Load JavaScript files asynchronously.
  • Modernizr – Use Modernizr or similar tool to test for specific browser features.
  • Footer Load Place scripts in footer of page.

JavaScript testing

  • ESLint – Verify JavaScript with ESLint or similar tool.

Security

Best Practices

  • HTTPS – Use HTTPS.
  • HSTS – Set HTTP Strict Transport Security parameter on web server.
  • Cross Site Request Forgery (CSRF) – Scrub and verify inputs, verify headers and use tokens.
  • Cross Site Scripting (XSS) – Minimize attack vectors and SQL injection by sanitizing input data and tracking logins and sessions.
  • Encryption – Hash and encrypt passwords, credit card numbers, cookies, etc.
  • Password Reset – Set password rules and flow on all authentication pages like Registration, forgot password, change password.
  • Login Limits – Require ‘human’ verification after a defined number of failed tries.
  • System Information – Verify application, server, or database version or connection information not publicly viewable.
  • Roles and Rights – Verify authentication and authorization process.
  • Address Bar – Only show encrypted session values in address bar.
  • SSL – Verify certificate not expiring.

Performance

Best practices

  • Minified – Minimize HTML and enable gzip type compression on web server.
  • Lazy loading – Load images, scripts, and CSS files as needed, not on load.
  • Cookie size – Minimize size of cookies.
  • Content Delivery Network – Push CSS, JavaScript, fonts, and generated HTML to CDN.
  • HTTP Cache Headers – Set approriate parameters.
  • DNS Prefetching – Enable preload and/or dns-prefetch.
  • Mixed Content – Retrieve all files and assets via HTTPS.
  • Logging – Enabled tools and verify data passing to monitoring platforms.

SEO

Best Practices

  • Indexing – Enable search engines to index site.
  • Tag Manager – Set up and verify data passing to tools.
  • Analytics & Conversion – Google Analytics and similar tools installed,correctly configured, and registering data.
  • Ad Pixels – Verify all ad pixels installed and registering.
  • Heatmaps: Verify installation, configuration, and data flow to third party tools.
  • A/B Tests: Verify installation, configuration, and data flow to third party tools.
  • Chat – Verify installation, configuration, and data flow to third party tool.
  • Sitemap XML – Set up auto-generation and submission of site, image, and video XMLs to Google Webmaster Tools and similar tools
  • robots.txt – Verify robots.txt not blocking any pages.
  • Structured Data or Rich Snippets – Generate error-free structured data as needed.
  • Title – Use unique title tag used on each page.
  • Description – Set unique meta description on each page.
  • 301 Redirects – Return 301 for moved content
  • Title Attribute – Set title attribute for all links.
  • Social Widgets – Connect social accounts and set up to show buttons / links in right places.

Legal

Best Practices

  • Privacy Policy – Create page and put link in footer.
  • Terms of Service – Create page and put link in footer.
  • GDPR Compliance – Show consent notice visible.
  • Copyright – Show in footer.

Prelaunch

Best Practices

  • Backups – Check backup and restore systems functional.
  • Versioning – Branch or tag production code in version control system.
  • Contact Forms – Set CAPTCHA functionality, required fields, validation, and verify information emailed or routed to CRM.
  • Newsletter Forms Check signup forms functionality and verify user information pushed to third-party tool.
  • Comments – Set moderation notices be sent to appropriate email addresses.
  • Search – Verify CMS search or Google custom search traversing only necessary data, and returning correct results.
  • API Configuration – Set live domain to be witelisted with third party intergrations or SaaS tools.
  • Dev Domains – Verify database and assets not referencing dev, staging, or QA environments.
  • DNS – Verify proper set up.
  • Conversions & Funnels – Set analytics tools to collect visitor clickstream.
  • Payment System – Turn off test mode off and transactions work.
  • www / non-www – Set non-canonical to redirect to canonical and preserving URL.

WordPress

Best Practices

  • .htaccess – Set with appropriate settings.
  • Navigation – Set navigation and sub menus to always be accessible.
  • Pagination – Set next and previous links go to right content
  • Database Table Prefix – Change from wp_.
  • Plugins – Remove unused plugins.
  • Themes – Remove unused themes.
  • Version – Remove generator meta in header.
  • Admin Account – Rename from admin.
  • Security Key – Change from default.
  • Admin URL – Change from default.
  • Default Content – Remove default posts, comments, and pages.
Digital Ocean + Workflow app: Check Status

Digital Ocean + Workflow app: Check Status

Below is a workflow I put together to have the Workflow app check the status of specific Digital Ocean droplet.

Why would I need to do this? Occasionally I build Tensforflow models. With a 2GB RAM instance, I can do some data validation and tests on a small amount of data. When I need to do full throttle testing and training, I need to resize the droplet to a 16GB RAM droplet. Usually, I’ll kickoff the resize walking to my car on the way home. Then I start the test and train steps when I get home. When done, I shrink it all back. There are five workflows for this cycle:

  1. See if specified droplet is active (this post)
  2. Power off specified droplet (future post)
  3. Power on specified droplet (future post)
  4. Resize droplet to 16GM RAM size (future post)
  5. Resize droplet to 2GB RAM size (future post)

A few caveats. First, I’m not sharing this through the official Workflow gallery simply because it could be improved significantly, but it does what I need it to do well enough. Second, I prefer to build workflows that do one task and just one task. It’s a Unix thing (ignoring the ‘well’ part, though).

Some familiarity of creating workflows will help following these steps.

Step 1: Create a new ‘Today Widget’ workflow.

Step 2: Get or generate your Digital Ocean API key.

Step 3: Get your droplet id. The easiest way would be to pull it from the dashboard when looking at your droplet. So go on your dashboard, click on the droplet, look at the URL. It should be something like https://cloud.digitalocean.com/droplets/<droplet id>/graphs.

Step 4: Add the fields and set the variables as shown above.

  • Note: Set the URL variable to https://api.digitalocean.com/v2/droplet.

Step 5: Continue adding fields and setting variables as shown in the screenshot above.

Step 6: Continue adding fields and setting variables.

What you see when you run with workflow from the ‘Today Widget’ is below.