Capture Anonymous Visitor Activity Based on Business Logic

April 17, 2014 | by

Imagine you want to track users who visit a specific post on your company blog. Let’s say out of the total number of users who visit a post, you would only like to track users who signal their interest by spending at least 5 seconds and scrolling down the page. For anonymous users you would like to create a new lead in Marketo with this event, and for known users you would like to update their lead activity with this event. You can accomplish this by using the Munchkin tracking code on your website.

When a non-cookied user goes to a page with the Munchkin tracking code, a new cookie will be created and stored on the user’s browser, and a new anonymous lead will be created in Marketo. If the user is already cookied and the user is an existing lead in Marketo, the visit to the page will be recorded in the activity log of the user in Marketo.

We’ll show you first how to generate Munchkin tracking code in Marketo, second how to modify your Munchkin sample code to only trigger if certain conditions are met, and third how to verify that a page visit from an anonymous user was recorded in Marketo.

How to Generate Munchkin Tracking Code

The Munchkin tracking code allows you to track visits to your web site. There are three types of Munchkin code described below, but in this example we will use the Asynchronous Munchkin tracking code.

A) Simple: has the fewest lines of code, but does not optimize for webpage loading time. This code loads the jQuery library each time a webpage is loaded.

B) Asynchronous: reduces webpage loading time. This code checks if the jQuery library already exists, loads it if it’s missing, and uses it for executing tracking code once the rest of the webpage has loaded.

C) Asynchronous jQuery: reduces webpage loading time and also improves system performance. This code assumes that you already have jQuery, and does not check to load it.

1. Click Admin at the top right of the app.

1

2. Click Munchkin in the tree on the left.

2

3. Select Asynchronous for Tracking Code Type.

3

4. Click and copy the Javascript tracking code to put on your website.

4

Code Sample to Cookie User and Track Event

Place the tracking code on your web pages right before the </body> tag. Landing pages created in Marketo automatically contain tracking code, so you don’t need to put this code on them.

6

This code sample would call the Munchkin API after the script is loaded:

This code sample would call the Munchkin API after the user has been on the page for 5 seconds and has also scrolled 500 pixels down the page:

How to Verify Page Visit by Anonymous User Was Recorded in Marketo

1. Click on Analytics in the top menu, and then click on New Report. Choose Web Page Activity as report type, and then name your report.

Screenshot - Web Page Activity

2. After you create a report, click on Smart List. Then select the Visited Web Page filter from the box on the right. Enter the web page where you put the Munchkin tracking code.

Screenshot - Smart List

3. Click on Setup. Select Anonymous Visitors from ISPs, and change option to Shown.

Screenshot - Show anonymous

4. Click on Report. You will now see activity tracked on the web page you selected.

Screenshot - Report 1

5. Double click on the lead record, which will then show the activity log where you can see the specific page the anonymous user visited.

Screenshot - Report 2

* This article contains code used to implement custom integrations. Due to its customized nature, The Marketo Technical Support team is unable to troubleshoot custom work. Please do not attempt to implement the following code sample without appropriate technical experience, or access to an experienced developer.