Forum Discussion

gstelang's avatar
gstelang
Mentor
10 years ago

Can we use macros in velocity email templates?

 

We're looking to track the user clicks on an email sent and we're doing that by passing a query string param. The problem is I cannot just append to the URL's in the email template.

 

/foo/bar#M436?referer=1 is invalid URL 

 

whereas I need to do : /foo/bar?referer=1#M436.

 

To achieve this, I need to parse url with something like...

 

#macro( parse_url $url)


  #set ($hash_index = $url.indexOf('#'))
  #if( $hash_index > -1 )
   #set ($first_part = $url.substring(0, $hash_index))
   #set ($second_part = $url.substring($hash_index))
   #set ($new_url = "${first_part}?referer=1${second_part}")
  #else
   #set ($new_url = "${url}?referer=1")
  #end


#end

 

#parse_url( ${notification.message.webUi.url} )

 

I have had no luck to get this to work : http://velocity.apache.org/engine/1.7/user-guide.html#velocimacros

 

It does work, however, if I get rid of the macro. Any input is appreciated. 

 

Also - does Lithium provide any tracking through a dashboard on number of click activity via email? 

No RepliesBe the first to reply