Re: Velocity Scripting: Asset information

Carlos_Correa3
Level 2

Velocity Scripting: Asset information

Hi there,

I'm trying to implement a velocity script (vs) that runs for multiple cases and allows me to use the name of the asset as a utm_id for my Google Analytics (GA) tags. So, that way, my script can be on the campaign folder level, or the workspace level if possible, to compose the redirect for GA, removing that customization aspect from the links.

In my vision, all I need to ask the agency is Please make sure that all your links are finished with ?{{my.redirect}} where redirect is my vs which will take care of the creation of the redirect depending on the name of the email that is being deployed from.

The bottom line questions is, can I access the asset name that is running the velocity script? so I can create a redirect with ?utm_id=My_cool_email because the name from which is running is named my_cool_email?

Thanks!

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting: Asset information

I'm a great champion of Velocity, but I think you're barking up the wrong tree here.  VTL doesn't have any better access to the name of the asset than a standard token -- why not use {{Program.Id}} or {{Program.Name}}?

Carlos_Correa3
Level 2

Re: Velocity Scripting: Asset information

Hey Sanford,

Thanks for the answer, The reason is because I'd have two emails in the same program and I cannot separate them, for AB Testing for example.

My solution will probably go down to using asset variables and controlling the redirects in there (at least for AB Tests), I was kinda hoping to have VS make that decision for me. Thanks!

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting: Asset information

Velocity does have access to the unique Email ID, though not, IIRC, the Email Name (which after all isn't unique).

Carlos_Correa3
Level 2

Re: Velocity Scripting: Asset information

interesting still... How does one refer to the id of the email? This is more for general curiosity now, I don't think I have a use case for it, but you never know.

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting: Asset information

#set( $emailId = $mktmail.xMarketoIdHdr.split(":")[5] )

Carlos_Correa3
Level 2

Re: Velocity Scripting: Asset information

Oh wow! That $mktmail object... looks very interesting! Where did you get that .xMarketoIdHdr attribute? is there any documentation regarding the $mktmail class? (Assuming it's OOP)

And after reading above, the thread just reeks of coding geekness! But oh well!

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting: Asset information

is there any documentation regarding the $mktmail class?

It's not documented (and subject to change, one supposes). I've done a lot of introspection of Velocity over the years for special projects so there are things that are top-of-mind that are of little use to anyone.