AnsweredAssumed Answered

... transferring discussion from Whisperer Blog on Custom Activities

Question asked by Sanford Whiteman on Mar 12, 2018
Latest reply on Mar 13, 2018 by Sanford Whiteman

Moving the discussion on Custom Activities in Marketo here to Products as the other place doesn't have a syntax highlighter.

 

Francesco as I was saying, even if your pages use the pathname for the search terms, we can transfer them into the query string (this will be cosmetic from the standpoint of the search engine, but Munchkin will log it for us) to take more intelligent action on the Marketo server.

 

Using this code, you'll end up with a Visit Web Page hit to /transferred-search-terms with {{trigger.Search Query}} available for use:

 

(function(loc){ 
  var transferLoc = document.createElement('a'), 
      pathParts; 

  transferLoc.href = loc.href; 

  if( pathParts = transferLoc.pathname.match(/\/search\/node\/(.*)/) ){ 
    transferLoc.search = "s=" + pathParts[1]; 
    history.replaceState({}, null, transferLoc.href); 
    Munchkin.munchkinFunction( "visitWebPage", { url : "/transferred-search-terms" }); 
  } 
})(document.location);

Outcomes