How to show file name in a download event?

I have created an event in the Tag Manager that triggers when files are downloaded and it registers the URL where each individual file is. It works great, but I would like to register the name of the file in the same way, how do I do this?

Thanks.

Hi @plinn ,

I guess you have to create your own variable (type Custom-JavaScript) in the Tag Manager where you use JavaScript to extract the file name from the clickURL.
You need some JavaScript knowledge. Here is an example for extracting from an URL.

1 Like

Yep that’s what I wanted to do, but I run into a problem. I asked about it on here too: Problem with Custom Variables in Tag Manager

I did this with a custom JavaScript variable and I put this code in it:

function () {
	let url = {{ClickDestinationUrl}}
	let n = url.split("/");
    return n[n.length - 1];
}
1 Like