Custom Campaign Tracker with Querystrings as variables.

Hey Folks,

 Been working on figuring out how to include some variables in the trackers.

 Essentially, I have a custom field that I need included in the custom tracker. That specific variable would send an API call and populate the page with the correct info for that specific target.

 So I really tried everything. 

{custom tracker link}?querystriring=$custom_field_c in the email template wasn’t working. It was being rewritten for some reason. I never sorted it out.

However if I did something like

https://www.mydomain.com/mypage.html?querystring1=$custom_field1_c&querystring=$custom_field_2

would work, but then there’s no tracking. So whats’ was a guy to do?

In the end I ended up going with a standard link to the page, and including the actual tracker link variable in the url to the page like so:

https://www.mydomain.com/mypage.html?querystring1=$custom_field1_c&querystring=$custom_field_2&tracker={custom tracker link)

The {custom tracker link} send a couple of querystrings of it’s own. That’s why it wouldn’t take my custom fields as variables. The structure of the tracker link is:

https://suitecrm.mydomain.com/index.php?entryPoint=campaign_trackerv2&track=customtrackerid&identifier=thisistheemailidentifier

entryPoint = What is Suite doing?

track = The campaign ID

identifier = The custom ID for that specific email that was sent to the target

So now we just have to reconstruct that URL when the customer get’s there. Once the tracker link is hit, then it registers in the campaign.

Then I would let the PHP on the page pull all the data for the target first, and use a document.ready script to call the tracker URL to a hidden div like so:

// This is the target for the custom tracker once the page loads.


<div id="tracker">
</div>

<script>
	$(document).ready(function() {
		$('#tracker').load('https://suitecrm.mydomain.com/index.php?entryPoint=campaign_trackerv2&track=<?php echo $_GET['track'] ?>&identifier=<?php echo $_GET['identifier'] ?>');

	});
</script>

That’s it. It’s hacky for sure, but figured I would share with everyone.

1 Like

This is a neat trick and proves you are a resourceful person :slight_smile:

Maybe you could have more control by customizing this file:

modules/EmailMan/EmailMan.php

from a quick look I think around line 794 is the code to construct those URL’s, you can adapt that to fit your needs.

If you do something generically useful - like allow for more variables to be included in tracker URL’s, you can consider contributing that code into the main product.

@Jack,

Great idea. This is exactly what we’re looking for. I note we’re almost 2 years from your first post so are there any updates or learnings since then?

Many thanks

Steve