Example of Online Marketing Custom Macro

Gabor Ferencz asked on May 20, 2015 15:20

Hello, I'm looking to extend the online marketing framework, by writing some additional rules and macros. We have a custom table that contains a list of products mapping to other products, so that if product A is purchased, then an email containing product b is sent out to the contact.

I have seen the "purchase" activity, so that would be a good trigger, but how can I create the next step that says - "does the product purchased exist in the custom table?"

Does the last order/product exist in the context?

Or is it just a case that we accept that a trigger has been fired - a purchase has been made, and we make a call to a custom macro, passing the contact, and then look at the contact's purchases in the last day and go from that data?

Any help would be appreciated.


Recent Answers

Petar Kozjak answered on May 20, 2015 15:49


I think both approach are good. Trigger after purchase or check purchase in last day. There is something like "Made purchase in last X days"...

You can start process after purchase, but I would place wait step (1 days, few hours). Your customer will get invoice so you don't want to bombard them with e-mails.

So it would look like this:

  1. Customer buys a product - process is triggered
  2. Step evaluates Product A relationship - Custom macro or code can check if this product A has some relationship return TRUE or Product B ID (so you can reuse it in E-mail). If it is null or empty process ends
  3. Create wait step just to give some time to customer
  4. Send e-mail with offer for product B
0 votesVote for this answer Mark as a Correct answer

Gabor Ferencz answered on May 20, 2015 15:53

Thank Peter, That's the solution I got to, but I would still be really interested to see an example of creating a custom trigger extension to Kentico. Have you ever done something like that?

Trigger process if purchase has been made THAT matches pre-requisites.

0 votesVote for this answer Mark as a Correct answer

Petar Kozjak answered on May 20, 2015 15:58 (last edited on May 20, 2015 16:00)


you will need to write custom code for that. Here is one example: http://www.mcbeev.com/Blog/August-2014/Kentico-8-Marketing-Automation-Sample-Code-Snippets

But I think you can do it using macros. Let me give you some idea: Contact.Orders.OrderBy("OrderID DESC").FirstItem and with same logic I think you can call custom table and then compare it.

But why haven't you used related documents option? I think in that case you can use macro to evaluate relationship and no custom code is needed: https://docs.kentico.com/display/K8/Displaying+related+documents

These are just ideas. I didn't test them, but we had similar scenarios.

0 votesVote for this answer Mark as a Correct answer

David Komárek answered on June 10, 2015 08:31

Hello Gabor,

you may also try using the additional condition for your trigger similar to: GlobalObjects.CustomTables["customtable.SampleTable"].Items.Exists(MyProductID == Activity.ActivityItemID) Please note that it may affect performance if the custom table is large and might be better to use a custom macro.


0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.