Skip to main content
Known Participant
March 3, 2022
Answered

Update 800 hyperlinks with UTM tracking

  • March 3, 2022
  • 1 reply
  • 1670 views

My client would like to add tracking to all their hyperlinks across 7 files, between 800-2200 SKUs each. This is not a batch find and replace situation, UTM was never used up until this new request,  so I don't think IDML option will work.

 

Is there a way to batch add the UTM tracking to all hyperlinks?

This topic has been closed for replies.
Correct answer brian_p_dts

Assuming the UTM needs to be appended to the end of all existing Hyperlink URL Destinations in the document: 

var hlds = app.activeDocument.hyperlinkURLDestinations;
var utm = "?utm=blahblah";
for (var i = 0; i < hlds.length; i++) {
    hlds[i].destinationURL += utm; 
}

 

1 reply

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
March 3, 2022

Assuming the UTM needs to be appended to the end of all existing Hyperlink URL Destinations in the document: 

var hlds = app.activeDocument.hyperlinkURLDestinations;
var utm = "?utm=blahblah";
for (var i = 0; i < hlds.length; i++) {
    hlds[i].destinationURL += utm; 
}

 

cr06canAuthor
Known Participant
March 3, 2022

Wow - Brian - brillant. Haven't worked with scripts very much. What/where exactly am I using this beautiful set of instructions?

 

brian_p_dts
Community Expert
Community Expert
March 3, 2022

The above code is a jsx script. This explains how to install and use it. You'll need to run it on an open document (won't do all docs at once--that costs extra 😉 )

 

https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post/