Python Errors in Windows

So I took a Data Science bootcamp and as the only PC in the room, I found myself figuring out some issues on my own. Figured I’d document them in case others run into the same issues:

“ImportError: DLL load failed: The specified module could not be found”

Having trouble with seaborn and plotting graphs.
Solution:


Error with Textblob

Couldn’t get textblob to run
Solution: Do a normal install, “import nltk”, then run nltk.download(). This opens up a GUI installer.

I’ll continue to add more as they pop up.

Autofill Forms from Email Merge Fields

So, I always hate it when I receive an email from a company to sign up for an event or download a white paper, but when I click to get to the offer, they couldn’t be bothered to pre-populate the form with information about me they clearly already had (Name, Email, etc.). This is a bit challenging without a CRM, but if you have a good mail client, it can be done easily.

Create a Form:

See example-form.html below.
contact-form

Create The Form URL

Go to your email provider, and identify the merge fields you need. I use MailChimp which you can identify the merge fields for your list by crafting a campaign and in a text box clicking “Merge Tags”:

Once you’ve identified the merge fields, you can create the URL which will be structured very similarly to a UTM tagged URL:
mailchimp-url

After you regular URL like example.com/webinar add a question mark (?), then an identifier, I use “first” for first name. Set the merge tag to equal it, so first=*|FNAME|* if you’re using Mailchimp. That is one field set. To add additional, add an ampersands (&) and another identifier set equal to a form field. Continue until you have all the fields you need.

Add the jQuery Script to All Pages with Form

See example autofill-forms.js below.

This small script will read your URL and identify the information following the question mark and match up your identifier to the field. This should be added to every page the form is present on.

Identify the fields you want to auto-fill and fill them in, i.e. #firstname below corresponds to my input field with the ID of firstname. The name indicated on the right, i.e. “first” is the identifier we used in MailChimp before each equal sign. You can add additional fields as they become necessary.

Test Your URL

Once that has been put in place, test the URL to ensure the fields populate well. If you have the merge tags in place, it should fill with that tag since that is parsed through Mailchimp:

register-merge-field

Once you verify that that URL works, test your merge fields by entering preview mode in MailChimp and choosing “Enable live merge tag info”:

mailchimp-preview
(See the URL at the bottom left for the button I’m hovering over). Click through a few of your subscribers to make sure the merge fields look correct.

Codes

P.S. – Using Google Forms? Check out this easy tutorial

Tracking Event Values from Formstack to Google Analytics

Let’s say I have the Formstack Form below and really want to capture the data of “Amount of Expense” and the User ID that is auto assigned to each submission, in Google Analytics. How would you go about that?

formstack

Set Up On Formstack

  • Within Formstack, navigate to the form > Settings > Emails & Redirects > Confirmation Emails > “Click to Add One” > Content: Custom Message. (You won’t be composing a message, just getting a few variables out of Formstack.)
  • Within the body, select the Unique ID & whatever field have the monetary (value) amount you’d like to capture. Remember that you cannot put personally identifiable data in Google Analytics, so don’t try to capture email, last name, etc. in Google Analytics.
  • Take note of the user ID tag and the tag associated with the expense amount.
  • Press cancel without saving, once you’ve copied that information.

formstack-email-ids

  • Once that screen is closed, navigate to “After the Form is Submitted” within the same page.
  • Select “Redirect to an External URL”, and insert your thank you page URL.
  • Immediately after, add a question mark (?) for a query. Within that query add the user ID tag.
  • Following that tag, add a hash symbol (#) followed by the tag for the expense, as you see below: www.example.com/thankyou.php?{$_submission_id}#{$37021767}.
  • This results in your thank you page having the data passed in the URL so that Google Analytics can parse it.submit-action-form

Set Up Google Analytics

  • Ensure that you have Google Analytics installed on the page the form is embedded and the form’s thank you page.
  • Next, add this script to your thank you page. It will pull the parsed information into Google Analytics as an event submission.

Results

Now the data will go into Google Analytics on each submission.

You’ll also be able to compare the Event Label within Formstack, under Submissions to match it up to the Personal Identification Information:
formstack-submissions

More Information

This tactic can also be use by taking advantage of Google’s Custom Dimensions and Metrics with Google Tag Manager.

time

Triggering a CSS Event Based On Time

At work one day, I had a client request a website change at 6PM and I wouldn’t be near a computer to make the simple text change. Since we don’t have a content management system, it was up to me to devise a solution.

So to trigger the change, I used a little bit of jQuery. This basic script just says, if the month is 11 (December) and the date is less than or equal to the 22nd, then any element with the class “remove” will show and any element with the class “show” will be hidden. When the date becomes December 13, then any element with the class”remove” will be hidden and any element with the class “show” will be visible.

With this quick script I can specify the minute, hour, day, month and/or year that I’d like certain elements to show by assigning them a CSS class of remove or show. The time is based on your server’s time.

More Info

• More about JavaScript Operators
• More about JavaScript Date Referencing
Stack Overflow Question That Inspired The Post

no-data-recieved-error

(Temporarily) Resolve the Server Reset/No Data Received WordPress Error

I use GoDaddy as my hosting and obviously have a WordPress install. A few months ago, I started running into this error on Google Chrome: “No data received [ERR_EMPTY_RESPONSE] Unable to load the webpage because the server sent no data.” I got a similar message in Firefox: “The connection to the server was reset while the page was loading.” This happened whenever I tried to make a new post and really put a damper on my blog activities on my various blogs.

I searched numerous forums, checked out my GoDaddy CPanel, looked at my FTP files, uninstalled & deactivated plugins, and made sure WordPress & plugins were all up to date. Still nothing worked! I did discover that the error could be triggered when editing files, as well though.

Becoming frustrated, I checked line-by-line of a draft to see what triggered the error, and I discovered it. The error occurred anytime a post had links with “http:” & “https:”.

(Temporary) Solution

Obviously removing the protocol declaration from links (and images) in a blog post could be problematic if I needed to link externally but thankfully, you don’t need to declare a protocol to make links. You can instead point to a website like this: //www.google.com instead of http:||google.com (slashes would be here instead of pipes obviously).

With any post I now make, I just make sure my links use protocol-relative URLs instead of declaring the protocol and I no longer receive errors. Unfortunately, I have yet to discover the root cause of the problem, but for the time being, it allows me to blog again while I figure it out.

linkedin-recommendations-me

How to Ask for a LinkedIn Recommendation via Email

The other day, I realized that I didn’t have any LinkedIn recommendations, and being in consulting work, I needed some social proof. So my first thought was to use the built-in recommendation form provided by LinkedIn:

linkedin-recommendation

But then I thought, how many people actually read emails that come in from LinkedIn. What were the chances that the request would go unseen, thus unanswered? So I thought there must be a way to just send someone a direct link to recommend me via email.

How to Get A Direct Link to be Recommended (Prior to 2017):

  1. View Your Own LinkedIn Profile
  2. Scroll to the Bottom where your Recommendation Area Is
  3. Under, “Would you like to recommend?”, right click and get the URL of the link: “Recommend YOURNAME”.
  4. The URL is structured something like this: www.linkedin.com/recs/give?memberId=00000000
  5. Use that URL to construct an email to your desired recommended (make sure you’re connected to them on LinkedIn).

This is where the URL links to (once they sign in):

linkedin-recommend-me

 

How to Get A Direct Link to be Recommended (2017):

  1. Use the URL: https://www.linkedin.com/in/YOURUSERNAME/recommendation/write/
  2. It will take the user to a page that looks like this that prompts for relationship & position then asks for your recommendation:

    LinkedIn Recommendations

Thanks, Ethan Anderson for letting me know about the update!

How To Ask For A LinkedIn Recommendation

I could write something up about that but there is a lot of great articles already about it, so here are two I recommend:

 

Be Broke at 25 Not at 75: Why You Should Save Now

Nerdwallet just released a study that says “New Grads Won’t Be Able to Retire Until 75.” Yes, that means you. You will have to wait 50 years before you retire if you were fortunate enough to be born in the early 90s or late 80s.

Why is that?

Well, mostly student loans and high rent costs, but let’s be honest, you already knew that…

What can you do about it?

Well, clearly the obvious answer is save more money. Yes, you’re thinking… well, I have those student loans and high rent to pay! Yes, I understand that but opt for the bus a bit more and your Ubers a bit less. Actually eat the food you purchase from the grocery store instead of throwing it out. Learn to cook meals with said groceries. Kick expensive habits, i.e. weed, cigarettes, alcohol, designer anything, and cancel that gym membership you’re not using.

Why can’t I just wait?

Well, because of compound interest. There is literally not been a single chart that compelled me to save more money than this one below. Don’t be Bill. Bill screwed up. $5000 is $416 a month and even less if you’re using a tax-deferred plan like a Traditional IRA or that employer plan you keep meaning to put money into.

compound interest

(Source)

But I’m afraid to invest, remember what happened in 2008?

I get it. It’s scary to toss all your money where you don’t have access to it and you may lose money but that’s why you (should) have an emergency fund! The rest of the money you put in the market, you won’t (or at least, shouldn’t) need for 40 years so really it doesn’t matter what’s going on with it til then.

Daniel Sheehan, a certified financial planner on NerdWallet’s Ask an Advisor platform says, “My advice to millennials I speak with is to realize that throughout the history of the investment markets, there have always been traumas… For those who invest wisely — allowing the market time to do its work by compounding — there isn’t a better way to invest for their future than the stock market.”

Essentially, shit happens. So, be there when the good shit happens too!

Fine. I get it. What can I do to get started?

  1. Contribute up to your employer match into your retirement account because it’s a 100% guaranteed return.
  2. Figure out how much you can stand to contribute to your tax-deferred retirement account. Remember it’s pre-tax so here’s a nifty calculator to figure out how it will affect your take home pay. It’s not as bad as you think! Save 20% and you’ll likely be able to retire at 62.
  3. Check out the article from Nerd Wallet that gives you more steps to make sure you have cash when you’re in going grey.

Trust me, it’s worth a bit of discomfort now to not be eating cat food when you’re in your 80s!

4 Quick Ways to Enhance Your Google Analytics Data

(Originally posted on the Betamore blog)

#1 Enable Demographics + Interest Reports

Why?

Adding one little line to your tracking code will allow for rich data about your site visitor’s age, gender & interests. Once you have that data you can create segments to see how your female visitors behaviors differ from your male visitors or what movie lovers are looking for on your site.

How?

  1. Go to Admin > Property Settings
  2. Enable Demographics and Interest Reports
  3. Go to Tracking Info > Data Collection
  4. Enable Advertising Reporting Features
  5. Update your tracking code:

GA_blog1

Example Result:

GA_blog2

 

#2 Set Up Google Webmaster Tools

Why?

When you want to see what keywords are driving to your site and all you see is (not provided), Google Webmaster Tools can solve that. What Webmaster Tools does is aggregate your search queries to eliminate “(not provided)” and allow you to reclaim your keyword data.

How?

  1. Go to Admin > Property Settings
  2. Select Adjust Webmaster Tools
  3. Under Webmaster Tools Site, select Edit
  4. Add Your Website Property
  5. Verify Your Website Property

GA_blog3

Example Result:

GA_blog4

 

#3 Bot Filtering

Why?

Having spam traffic in your analytics throws off all your data. There’s advanced settings that will allow for more bot filtering, but this simple step will help you begin to eliminate some of that.

How?

  1. Go to Admin > Property Settings
  2. Enable Bot Filtering

GA_blog5

#4 Set Up Filters

Why?

This can be as simple or as complex as you’d like to make it, but filtering allows you to get only the real data you want. You can exclude IP addresses, remove spam, change all your URLs to lowercase, and much more. Get started with “Three Google Analytics Filters You Should Be Using Today

How?

  1. Admin > Filters

GA_blog6

Example Results:

GA_blog7

12 Money Questions We’re Not Asking Our Friends, But Should Be

We need to talk about money. It’s 2015. We talk about literally everything else at this point. Scroll through any feed you have and you’ll see people complaining about their relationships or lack thereof, articles about new positions to try, someone you went to high school with saying something mildly racist, defenders of guns, people against guns, people discussing their open relationships, people not vaccinating their kids and countless “I Side With” political quiz results. How did salary become the only thing we’re NOT allowed to talk about?

Are you in credit card debt? How did you deal with it? Does it all stem back to that free t-shirt from freshman year?

When I was 18, I just racked up debt because that was future me’s problem–thankfully I had a small limit. I had to figure out, on my own, what balance transfers were, how grace periods work, how valuable 0% interest is, and just how awesome an 800 credit score feels. It would have been great to have a friend around that could have stopped me from treating all my friends to dinner or tell me just because I have that credit limit, doesn’t mean I should spend up to it.

Next time you’re out to lunch with a friend you trust and they whip out their credit card to split the bill, ask how they like the card and slowly ease that into a conversation about your current or previous debt. Just because you got out of debt before, doesn’t mean you won’t relapse. Know you have that friend around for support.

Are you saving for retirement? Are you taking advantage of the company match? Have you figured out what a Roth IRA is yet?

Now that I’m older, I’m one of those weird people that get all warm and fuzzy when they save money. It’s like a runner’s high but without all the sweat. Allocating money into my 401K, Roth IRA & savings account is the highlight of my week. Most of my friends, not so much. I’ve taken it upon myself to be the nagging friend telling them to take the free money their employers are offering up. In your 20s, saving for retirement seems ludicrous when you have crippling student loans, rent you can barely afford and you’re still borrowing a friend’s Netflix password but the power of compound interest is too good to pass up.

Even if you’re not comfortable investing quite yet, it’s nice to have that one friend that is– view them as your aspirational goal. This is a good convo to have with someone higher up than you at work but only by 2 or 3 years. Learn from them, ask how much they’re putting away, how much they’re investing and where. Before you know it, you’ll be compounding interest like a pro!

How much was your mortgage? What exactly are closing costs? Is it insane to make a 30-Year commitment when you’re 25?

I’m at that point in my life where some people are buying houses while others can barely afford their bottomless mimosas. So, we’re all pretty confused. Since undergrad, I’ve been told that buying is cheaper than renting but I also really loved it when my landlord delivered my packages directly to my apartment. Why give that up for doing your own plumbing and a novel sized stack of paperwork?

The “cheaper to buy than rent” philosophy would mean a lot more to me coming from people that actually did it. Mortgage calculators, PMI, scrounging together a year’s worth of rent, surprise HOA fees, trying to figure out if you should work on saving 20% (does anyone save 20%?)–this is a lot to take the word of anonymous interneters. Talk to your friends, talk to your parents, talk to your boss over a casual Friday lunch. Get as much info as they’re willing to share.

How much do you make? How much of that goes to taxes? How do you know if you’re filling out your W4 right?

First of all, is there some class where they teach you how to fill that out properly that no one ever told me about?

Anyway, this is a biggie for most people. No one wants to disclose how much they make (even people that work for the government where it’s public information). Why is that? People worry that they’re underpaid, and their friends will judge them/pity them, or overpaid and they’re friends will ask to borrow money/resent them.

You need to get over that. We all need to get over that. I’m not saying slap your salary on the side of a truck like that Life Lock dude, but disclose it to people you trust, especially co-workers. Why? Because if you’re unhappy with your salary, you figure out what your earning potential can be or if you should have asked for more during negotiations. If you’re happy with your compensation, you can be an advocate for someone that you think deserves more.

As one of those people who’s salary is public information, I’m always checking out co-worker’s salaries and scoping out their Linkedin pages to see what skills I’m lacking to get me to that next level. I also take the opportunity to chat with friend’s about salary so we know what student loan programs to take advantage of, what tax credits we should plan for, and all those little intricacies in life where it’s nice to have a salary-buddy (a friend close to your salary) to complain to and share triumphs with.

So why talk about money? It’s those little conversations: “How much extra are you paying for HBO?” “How are those travel points working for you?” “How much is your car insurance?” that open the doors up for the bigger ones: “I’m turning 26 and I have no idea how much my health insurance is going to cost.” “I have $90K in student loan debt and I’m not sure how I’m going to pay it off.” “I don’t think we’ll ever be financially stable enough to have a kid.” That’s what friends are for.

Using Google Analytics with Accordions & Carousels

We just did a new website redesign with a combination of accordions and carousels. These two design components are flashy but I’m not always certain if they’re necessary (or if anyone actually cares) so I wanted to be able to track the clicks on both the carousel & the accordions.

It took some searching and I was able to figure out how to use jQuery and Google Analytics event tracking to do this thanks to a blog from Outlier.com.

Tracking Accordion Clicks as Google Analytics Events

So my accordion is designed with h4 as the accordionheader, as follows:

<div class="accordionheader">
<h4><a id="name" href="#name">Header Test</h4>
</div>

In order to track the click, I used:

<script>
$('h4').click(function() {

var linkText = $(this).text();
ga('send', 'event', 'accordion', 'click', linkText);
});
</script>

What this does it triggers Google Analytics to send an event when the h4 is clicked. The event is labeled as category = accordion, action = click and linkText refers to the text of the h4. If you wanted to make sure you tracked only opens, you could get fancy and mess around with accordion jQuery but I like to keep things simple.

Tracking Carousel Clicks as Google Analytics Events

So this seemed like it should have been easier because essentially, you’re just tracking clicks, but because a link could exist in the carousel and the page, I wanted to make sure I knew where that click was attributed to. I also wanted to track every time the carousel slide in order to accurately calculate ratios of impressions vs. clicks.

I used cbp-fwslider for my carousel. First my slide is encompassed within a unordered list with each slide as a list item, so each slide looks like this:

<li id="slide1">

<a href="link.html" target="_blank"><img alt="img01" src="images/6.png"></a>

<div class="carousel-caption-right wordwrap">
<h3>Heading</h3>
<small>Dummy text.</small>

<p><a class="web-seemore" href="link.html" target="_blank">Link Text</a></p>
</div>

<p id="captionone"><a href="Link" target="_blank">Link Text</a></p>

</li>

So then in order to track, I used the below code:

<script>

$('#cbp-fwslider').on('click', function() {
ga('send', 'event', 'slider', 'slide', {'nonInteraction': 1});
});
$('#slide1').on('click', function() {
var slideID = document.getElementById('slide1');
var slideLink = slideID.getElementsByTagName('a')[0];
var slideURL = slideLink.href;
ga('send', 'event', 'slider', 'slide1', slideURL);
});
$('#slide2').on('click', function() {
var slideID = document.getElementById('slide2');
var slideLink = slideID.getElementsByTagName('a')[0];
var slideURL = slideLink.href;
ga('send', 'event', 'slider', 'slide2', slideURL);
});
$('#slide3').on('click', function() {
var slideID = document.getElementById('slide3');
var slideLink = slideID.getElementsByTagName('a')[0];
var slideURL = slideLink.href;
ga('send', 'event', 'slider', 'slide3', slideURL);
});

</script>

What’s important to note is that the slide simulates a click on #cbp-fwslider so an event is sent on the simulated slide click. the note on NonInteraction set to 1 is to denote that this event should not affect bounce rate.

Following that, each slide’s ID is handled by their list-item ID and upon click of that list item three variables are set:

  • var SlideID = looks for slide1 on the page
  • var slideLink = looks for anchor (a) in the above mentioned slide1
  • var slideURL = identifies the URL within the above-mentioned anchor in slide1

Once these are defined, Google Analytics sends an event category = slider, action = click, label = the URL of the link as defined by the SlideURL variable.

This should be repeated based on how many carousel images you have. Just make sure you update the areas in yellow.

(Photo Source)