RevMail - generating custom UUIDs with Javascript

A guide to generating your own custom UUIDs

In order for impressions to be successfully tracked, a unique identifier (UUID) needs to be passed into the key parameter. If a UUID is not passed for each impression it will result in stats discrepancies. In the following example we're creating a UUID following version 4 specifications using some javascript.

Example of JS that can be used to generate a v4 UUID:

function uuid() {    
   var uuid = "", i, random;   
   for (i = 0; i < 32; i++) {      
       random = Math.random() * 16 | 0;        
       if (i == 8 || i == 12 || i == 16 || i == 20) {        
           uuid += "-";      
       }
       uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);    
    }  
    return uuid;  
}

Example of a v4 UUID generated from the JS above:

2e78a663-bfec-4638-91f9-5a4aa05090e3 

We would now be able to insert this UUID value into our key parameter, and the result would look like this:

key=2e78a663-bfec-4638-91f9-5a4aa05090e3

NOTE: the same UUID must always be passed into the key parameter of both the anchor and image tag