As Date/time AB split tests are very valuable to us, we'd like to go a step further, and track the result of each split in Google Analytics (we do a 50 50 split, one send in the morning and one evening send)

I've managed to make each name of the utm_campaign unique by using this AMPScript adding the hour of the send for each send to the campaign_name:

<script runat="server" language="ampscript">

var @utm 
var @splitversion 

set @splitversion = DatePart(Now(), "H") 
set @utm = CONCAT("http://dk.bonaparteshop.com?utm_campaign=171-25-TH-",@dyncountry,"-TEST-", @splitversion)


Adding the @utm to a link using:

<a href="%%=redirectto(@utm)=%%">CLICK</a>

and then clicking it, adds takes me to my site with this URL:


So far so good! But what I then had to realize was that utm_source, utm_medium, utm_content and utm_campaign attributes are system set to the URL of all my links. This means that the utm_campaign attribute is set twice and as Google Analytics only stores the last version of a duplicate utm_campaign all of the work above have been kind of effortless.

So: Any idea on how I could use the experiences described above to make my split test appear as two and not one campaign in Google Analytics?

Thank you

  • 1
    Try adding in JobID to your utm - Each send has its own unique Job ID, including if sent via the A/B testing tool in the UI. This way you can also differentiate on emails sent at same time/date (ie. subject line or content/copy testing) Jun 23, 2017 at 12:26
  • 1
    Thanks. I'm working on a modified version for a better setup than described above - a solution including the JobID. If I suceed, I'll surely post the result here Jun 26, 2017 at 12:22

1 Answer 1


So, I ended up doing a number of things.
First of all, I made a setup change to the tracking job of all mails sent from the marketing cloud. I changed it from being equal to the name of the mail to just being the value of the variable @TrackingString. Then I changed the header included in all my sends to setting the value of @TrackingString to the name of the mail. This is an important step, as the marketeer evaluating each send in Google Analytics just has to stick to the usual workflow.

Then, last thing to do, was to build a Free Form block containing this AMPScript:

<!--Script Blok TRACKING-->
<script runat="server" language="ampscript">
VAR @TrackingString
SET @TrackingString = concat(emailname_,'-',jobid) 

So, whenever I need to send a split test, I just need to add this block to the mail, and the split test will be split into 2 sends in Analytics, telling me how each send perform on our webshop. I don't need to change anything in the AMPScript, just need to remember to add the block and the campaign is changed for ALL links in my mail. It's an easy solution, giving me the flexibility I need and valuable information.

Hope it makes sense.

Thanks @Gortonington for the JobID suggestion - using the JobID in stead of the hour stamp described in the original question posted always makes sure the variable is unique making this solution useful on all types of AB split tests.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .