PHP

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

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!