Modx

Type
Fri Feb

Marketo API Driven Google Analytics Custom Dimensions

Marketo isn’t the best with reporting. I find their analytics to be quite janky, visually unappealing, and kind of annoying to build. Something I’ve wanted to do for a while…

Marketo isn’t the best with reporting. I find their analytics to be quite janky, visually unappealing, and kind of annoying to build.

Something I’ve wanted to do for a while is build in Marketo data into our Google analytics. I did this using Google Analytics Custom Dimensions.

Because I previously integrated MODX  with Marketo I am now able to pass lead data to custom dimension parameters in the Google Analytics javascript snippet that they provide.

As an example here is what I’m currently running on Google Analytics.

 


	  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
	  
	  ga('create', 'xx-xxxxxxx-x', 'auto');
	  ga('send', 'pageview', {
	  'dimension1':'[[!+mkto.Email:default=`Anonymous`]]',
	  'dimension2':'[[!+mkto.Industry:default=`Unknown`]]',
	  'dimension3':'[[!+mkto.modxSalesforceOwner:default=`Unassigned`]]'
	});

In this snippet I am measuring the email (unique lead identifier), industry, and salesperson of everyone that visits our site! This allows me to do some really neat stuff in google analytics when it comes to reporting, and I love me some google analytics reporting.

Leads

Screen Shot 2015-02-13 at 3.26.24 PM

Industries

Screen Shot 2015-02-13 at 3.24.58 PM

Salesperson Traffic

Salesperson Custom Dimension

Next up is measuring specific events, custom metrics, and other fun stuff. I’ll hopefully put up a post soon! 

View
Type
Tue Dec

MODx Marketo Integration for the XebiaLabs Website

XebiaLabs uses MODx for its content management system and Marketo for its marketing automation system. To integrate Marketo into MODx I came up with an extremely creative solution that used…

modx-and-marketo

XebiaLabs uses MODx for its content management system and Marketo for its marketing automation system. To integrate Marketo into MODx I came up with an extremely creative solution that used a custom PHP class to pull Marketo lead data from their SOAP API and then subsequently populate that data into corresponding MODx “placeholder” elements.

First I found a php client for pulling the information from Marketo’s SOAP API, they provide some code here to pull lead data, but I wanted something I could use to pull other information from their API. turns out, someone had already done much of the heavy lifting.

I then coded the below snippet that does the following.

Initially I check to see if I’m specifying a lead manually by passing someone’s email in a query parameter. This is a nice override for when I need to view pages as a specific person within our database. It’s also nice when I need to ensure that someone sees a webpage with their info. I can append the link I have in an email, for example, to include their email, and subsequently ensure they see they website as they should. They may not have a munchkin cookie after all.  If I view a user in this method I store the information in a session so that I don’t have to perpetually communicate with the Marketo API for future pageviews.

If I then view any subsequent page on the website my information gets pulled from the session.

If I don’t have a query parameter specified for a user, and I don’t have any sessions from a previous website visit I use the PHP client to see if their is a munchkin cookie in the user’s browser.

If their is I pull the viewers lead data using their munchkin cookie. Then, as with the query parameter example I store the user’s info in a session variable so that I don’t have to communicate with the API again.

After lead data is stored in a session or pulled directly from the Marketo API I am then able to pass the information to a built in MODx method for displaying information. I use something they call “Placeholders”.

Learn more about placeholders here.

Check out the code here:

This code is lacking some serious security precautions and error handling. It is being worked on for the future, and I will try to update. Please comment if you would like further direction.

View
Type
Sun Oct

Change MODx Resources to Cacheable In Bulk

Whenever I edit a MODx page I usually find myself making it uncacheable so that I can temporarily make quick updates and see the page in its new form upon…

Whenever I edit a MODx page I usually find myself making it uncacheable so that I can temporarily make quick updates and see the page in its new form upon each refresh. The problem is that I sometimes forget to make the page cacheable again when I’m done editing.

If you are careless like me then the following snippet might be useful for changing your MODx resources to cacheable in bulk. To do this simply specify the ultimate parent of the resources you would like to cache, the depth to go when collecting the resources to cache, and the sort order.

View

Subscribe for More!


I send out a monthly newsletter on various topics.

Take a moment to enter your details, and you can select the news you would like to have delivered to your inbox!