Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Capture last section of download link url

Avatar

Avatar
Ignite 1
Level 2
angelad64963316
Level 2

Like

1 like

Total Posts

43 posts

Correct Reply

1 solution
Top badges earned
Ignite 1
Validate 10
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Ignite 1
Level 2
angelad64963316
Level 2

Like

1 like

Total Posts

43 posts

Correct Reply

1 solution
Top badges earned
Ignite 1
Validate 10
Validate 1
Boost 1
Applaud 5
View profile
angelad64963316
Level 2

05-11-2020

hi

 

i would like to capture the last part of our long file download urls because it is much easier to report when they are friendly urls.  i know that i can use the following in a console to tell me the value of the page link. 

 

location.href.split('/').pop();

 

But i need this for the file download url which just happens to open in a new window, as expected behaviour for our website.

 

i feel like i'm close, i've tried to capture the value in an eVar; i've tried to use the value above in a data element but i'm not getting any joy.  Not sure where i'm going wrong.  Can someone put me out of my misery.

Analytics Download Links Launch.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
evolytics_brian
MVP

Likes

70 likes

Total Posts

145 posts

Correct Reply

44 solutions
Top badges earned
Establish
Seeker
Give Back
Engage 1
Boost 50
View profile

Avatar
Establish
MVP
evolytics_brian
MVP

Likes

70 likes

Total Posts

145 posts

Correct Reply

44 solutions
Top badges earned
Establish
Seeker
Give Back
Engage 1
Boost 50
View profile
evolytics_brian
MVP

05-11-2020

Hey, @angelad64963316  -

One easy way to do it would be to use the old doPlugins approach. Adding the following block of code to the "Configure Tracker Using Custom Code" section of the Adobe Analytics extension will evaluate every call to see if it is a download tracking call (s.linkType==="d"):

s.usePlugins = true;
s.doPlugins=function(s) {
  // custom logic here
  if(s.linkType && s.linkType === "d") {
    s.eVar1 = s.linkURL.split("/").pop();
    s.linkTrackVars += ",eVar1";
  }
}

In short, if the call is a download tracking call (triggered automatically based on the file extension OR triggered manually using the "d" identifier in the s.tl() call), we grab the destination URL (s.linkURL), pop off the file info and store it in eVar1, then update s.linkTrackVars to ensure eVar1 is on the call.

That should be all there is to it.

Answers (1)

Answers (1)

Avatar

Avatar
Boost 5
Employee
Khurshid_Alam
Employee

Likes

49 likes

Total Posts

176 posts

Correct Reply

37 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile

Avatar
Boost 5
Employee
Khurshid_Alam
Employee

Likes

49 likes

Total Posts

176 posts

Correct Reply

37 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile
Khurshid_Alam
Employee

05-11-2020

You may use custom link tracking.

<a href="#" onclick="
s.linkTrackVars='eVar1';
s.eVar1= url; // You need to write script to save the last part of url here
s.tl(this,'d','Download');
s.manageVars('clearVars',s.linkTrackVars,1);">
Download
</a>