Expand my Community achievements bar.

SOLVED

Event Trigger

Avatar

Level 2

I want one of my link event to only trigger after pageview call? I tried it by giving condition, but it's not working. Is there any way to sort it out?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Unfortunately, there is no real "chaining" of triggers like this... while the changing the order of rules, this may not actually run after the first rule.

 

The problem is that order is based off the start of the execution... so let's use some very simple numbers to illustrate this..

 

Let's say we have Rule 1 (set to the default order 50), and Rule 2 (set to order 100) - note, the order is just set this way that would allow other rules to be added between, there is no difference here between using 50 and 51 in this example.

 

Now, let's say that Rule 1 takes 5 seconds to run, and Rule 2 takes 2 seconds to run.

 

0 1 2 3 4 5
Rule 1 Starts ... ... ... ... Rule 1 Ends
... Rule 2 Starts ... Rule 2 Ends ... ...

 

You can see above that despite Rule 2 starting after Rule 1, Rule 2 finishes before Rule 1, making it look like Rule 2 was run first.

 

 

Now, if you have a dependency, wherein something in Rule 1 must finish before Rule 2, the best way to do this is to add Both of the actions into a single rule... 

 

Now, the actions while you can add them in order, can have 2 different behaviours... one is like the above ordering, where each code block starts in the order specified, but can end in different orders because they are run in parallel (THEN)... or you can actually set the rules to complete execution before moving onto the next action in the sequence designated.

 

To do this, you must first make sure that your Property is set to "run rule components in sequence" (this wasn't an option when Launch first came out, so depending on how old your property is, you may have to go into your property settings and check this box - new properties have this set by default now)

 

 

When you set multiple Actions inside the same rule, if you see this, then all the actions will run simultaneously (which is good if there are no dependencies, it will allow the rule as a whole to complete quicker):

 

Jennifer_Dungan_0-1703567635526.png


However, in your case, it sounds like you need Action 1 to complete before Action 2, so you want to see this:

Jennifer_Dungan_1-1703567705691.png

 

 

Action 1 will run and complete before Action 2 is run,

 

This is a simple setting, inside each Action, in this case, inside of Action 1:

Jennifer_Dungan_2-1703567779882.png

 

Each action has Advanced Options to allow you to choose whether to wait to run the next action in the sequence... 

 

You can even stack multiple Actions like this, mixing the behaviour... maybe you need Action 1 to complete, then Action 2 to complete, but then maybe you have Action 3 and 4 with no dependencies on one another (but still need Action 1 and 2 to be done):

Jennifer_Dungan_3-1703567951798.png



Action 1 and Action 2 are set to "wait to run next action", whereas Action 3 and 4 are not...

 

0 1 2 3 4 5
Action 1 Starts Action 1 Ends ... ... ... ...
... ... Action 2 Starts Action 2 Ends ... ...
... ... ... ... Action 3 Starts Action 3 Ends
... ... ... ... Action 4 Starts Action 4 Ends

 

If you really need different code blocks to be dependent on one another, adding them to the same rule is the best option..

 

I use this all the time, I have a "fundamental page tracking", then in here I add our Adobe tracking actions, and our FB pixels actions, and our Google Ad Words pixel actions, etc...

 

I do the same for "subscription success", one rule facilitating multiple types of tracking, and in this one I do specify some items to run in order, since I have to process some information that I have logic to include in the pixel conversions, so I just make sure they are deferred until after I have everything that I need.

 

-------

 

Now.. maybe this isn't what you are asking, because looking at your question, I can also interpret this as "we have some instances where people are clicking on links before the page view has tracked, and we don't want that to happen..."

 

This is a harder issue to fix, since if you page load times are slow, there is more of a likelyhood for people to click on your links while the page is loading, making your "link click" action fire before your "page view"...

 

In this case, what is it that you want to happen? The user will be taken away from the page, so the page view won't complete in this instance ever...  Do you want to prevent links from tracking IF the page view hasn't triggered yet (so you not only lose the page view tracking, you also lose the click tracking?) This is really the only thing you can do...  you can't stop the user from navigating away from the page, forcing the page view to track, then the link click....

 

If you really need to do the above, i.e. only allow link clicks to occur if the page view has been triggered

 

Then you could do a custom code "trick".. on your Page Load rule, you can add a window level variable to indicate that the page view tracking has completed (i.e. Add a custom code action as the last action in the rule to set something like:

 

window.pageLoadOccurred = true;

 

 

Then on your link click rules, add a condition to only run if window.pageLoadOccurred exists and is true (if you are running an SPA, this won't work, since once set, this will now be true on each subsequent page, but this issue is also less likely to affect SPAs as they shouldn't have delay page times that allow people to click before the "page view" action)

 

On a traditional website, each page load will reset the window.pageLoadOccurred to be undefined. Making sure your click rules won't be triggered until after your page load rule has fired.

View solution in original post

4 Replies

Avatar

Community Advisor

@souravc454 Did you try adding a higher order to the link event rule ? You can control execution to a certain extent by giving your link event rule a higher number than the default 50 (if the pageview rule has the default order of 50).

 

You can also try calling the link event from the pageview rule right after that one has executed by calling the _satellite.track('<your string here>') method and using this as a direct call event in your link event rule.

 

Try out the above and let us know how you go.

 

Cheers,

Abhinav

Avatar

Correct answer by
Community Advisor

Unfortunately, there is no real "chaining" of triggers like this... while the changing the order of rules, this may not actually run after the first rule.

 

The problem is that order is based off the start of the execution... so let's use some very simple numbers to illustrate this..

 

Let's say we have Rule 1 (set to the default order 50), and Rule 2 (set to order 100) - note, the order is just set this way that would allow other rules to be added between, there is no difference here between using 50 and 51 in this example.

 

Now, let's say that Rule 1 takes 5 seconds to run, and Rule 2 takes 2 seconds to run.

 

0 1 2 3 4 5
Rule 1 Starts ... ... ... ... Rule 1 Ends
... Rule 2 Starts ... Rule 2 Ends ... ...

 

You can see above that despite Rule 2 starting after Rule 1, Rule 2 finishes before Rule 1, making it look like Rule 2 was run first.

 

 

Now, if you have a dependency, wherein something in Rule 1 must finish before Rule 2, the best way to do this is to add Both of the actions into a single rule... 

 

Now, the actions while you can add them in order, can have 2 different behaviours... one is like the above ordering, where each code block starts in the order specified, but can end in different orders because they are run in parallel (THEN)... or you can actually set the rules to complete execution before moving onto the next action in the sequence designated.

 

To do this, you must first make sure that your Property is set to "run rule components in sequence" (this wasn't an option when Launch first came out, so depending on how old your property is, you may have to go into your property settings and check this box - new properties have this set by default now)

 

 

When you set multiple Actions inside the same rule, if you see this, then all the actions will run simultaneously (which is good if there are no dependencies, it will allow the rule as a whole to complete quicker):

 

Jennifer_Dungan_0-1703567635526.png


However, in your case, it sounds like you need Action 1 to complete before Action 2, so you want to see this:

Jennifer_Dungan_1-1703567705691.png

 

 

Action 1 will run and complete before Action 2 is run,

 

This is a simple setting, inside each Action, in this case, inside of Action 1:

Jennifer_Dungan_2-1703567779882.png

 

Each action has Advanced Options to allow you to choose whether to wait to run the next action in the sequence... 

 

You can even stack multiple Actions like this, mixing the behaviour... maybe you need Action 1 to complete, then Action 2 to complete, but then maybe you have Action 3 and 4 with no dependencies on one another (but still need Action 1 and 2 to be done):

Jennifer_Dungan_3-1703567951798.png



Action 1 and Action 2 are set to "wait to run next action", whereas Action 3 and 4 are not...

 

0 1 2 3 4 5
Action 1 Starts Action 1 Ends ... ... ... ...
... ... Action 2 Starts Action 2 Ends ... ...
... ... ... ... Action 3 Starts Action 3 Ends
... ... ... ... Action 4 Starts Action 4 Ends

 

If you really need different code blocks to be dependent on one another, adding them to the same rule is the best option..

 

I use this all the time, I have a "fundamental page tracking", then in here I add our Adobe tracking actions, and our FB pixels actions, and our Google Ad Words pixel actions, etc...

 

I do the same for "subscription success", one rule facilitating multiple types of tracking, and in this one I do specify some items to run in order, since I have to process some information that I have logic to include in the pixel conversions, so I just make sure they are deferred until after I have everything that I need.

 

-------

 

Now.. maybe this isn't what you are asking, because looking at your question, I can also interpret this as "we have some instances where people are clicking on links before the page view has tracked, and we don't want that to happen..."

 

This is a harder issue to fix, since if you page load times are slow, there is more of a likelyhood for people to click on your links while the page is loading, making your "link click" action fire before your "page view"...

 

In this case, what is it that you want to happen? The user will be taken away from the page, so the page view won't complete in this instance ever...  Do you want to prevent links from tracking IF the page view hasn't triggered yet (so you not only lose the page view tracking, you also lose the click tracking?) This is really the only thing you can do...  you can't stop the user from navigating away from the page, forcing the page view to track, then the link click....

 

If you really need to do the above, i.e. only allow link clicks to occur if the page view has been triggered

 

Then you could do a custom code "trick".. on your Page Load rule, you can add a window level variable to indicate that the page view tracking has completed (i.e. Add a custom code action as the last action in the rule to set something like:

 

window.pageLoadOccurred = true;

 

 

Then on your link click rules, add a condition to only run if window.pageLoadOccurred exists and is true (if you are running an SPA, this won't work, since once set, this will now be true on each subsequent page, but this issue is also less likely to affect SPAs as they shouldn't have delay page times that allow people to click before the "page view" action)

 

On a traditional website, each page load will reset the window.pageLoadOccurred to be undefined. Making sure your click rules won't be triggered until after your page load rule has fired.

Avatar

Community Advisor

Yeah right. The order does not gaurantee that execution of action 1 would complete before action 2 execution starts.

 

As usual, nicely detailed explanation Jennifer!

Avatar

Community Advisor

Thank You @abhinavbalooni  I have some complex rules in my setup, so I run into the "order" issue frequently

 

But for non-coders, I try to make the explanation as visual as possible cause it can be hard to understand technical explanations with order of operation and order of completion...