Find and Use the URID with JSP

Important Notes:

“mm_urid” is used in the examples below. If you have defined your own variable, please change ALL “mm_urid” references to the variable name you selected when setting up the click URL.

You must replace the default Goal ID (“12345”) with the App Tracking ID given to you by your Account Manager or when you registered on mMedia.

Don’t have an App Tracking ID? Do one of the following:

Step 1: Add the following code inside the header of each page that is a part of the conversion process.

...
<%
String urid = "";
urid = request.getParameter("mm_urid"); 
if (urid == "") urid = "No URID";
%>
...

This will ensure that the URID value follows the user throughout the conversion process.

...
<a href="thankyou.jsp?mm_urid=<% System.out.println(urid); %>" >Submit Conversion</a>
...

Step 3: On the final page of the conversion, place the following code.

Steps 1 and 2 ensure that the URID variable follows the user to this final page and is available.

The following code will grab the URID from the URL string and populate it within the the API call.

Once complete, it will automatically submit the conversion event to Millennial Media’s Conversion Tracking API.

...
<%
// Conversion Tracking Start
	
	String goalID = "12345";
	
	String urid = "";
	urid = request.getParameter("mm_urid"); 
	if (urid == "") urid = "No URID";
	urid = URLEncoder.encode(urid,"UTF-8"); 
	
	String tracking = "http://cvt.mydas.mobi/handleConversion?goalid=" + goalID + "&urid=" + urid;
	HttpURLConnection con = (HttpURLConnection) new URL(tracking).openConnection();
	con.setRequestMethod("POST");
	con.getOutputStream();
	con.getInputStream();
	
// Conversion Tracking End
%>
...