Reference Key for Analytics

With our SDK, you have the ability to track the conversion of your transactions by adding a reference key to your API. In order to benefit from this, you need to create the reference, add it the transaction instruction as well as add it to the POST response.

Create a unique reference

Use the code snippet below to generate a reference key:

const reference = Keypair.generate().publicKey; 

This allows you to generate a unique reference key.

Add the reference to the transaction instruction

Insert the reference into your transaction instruction as follows:

ix.keys.push({ pubkey: reference, isSigner: false, isWritable: false });

Enable experimental features and add the reference to your POST response

Include the reference in the POST response to track transaction conversion:

const response: TransactionResponse & {
    dialectExperimental: { reference: string };
  } = {
    type: 'transaction',
    transaction: Buffer.from(transaction.serialize()).toString('base64'),
    dialectExperimental: { reference: reference.toString() }, // 3. Include reference in response
  };

You can find a complete example with our Donate blink here.

Last updated