Hi Andrey,
As per our understanding there are 2 parts of your question ,1st being why the Event Based Rule you created for download link is not firing and the 2nd being How to basically create an event based data element such that the data element captures the processed href value of the download link and then can be further used in tracking codes.
Answer to 1st part of your question:
Generally if an event based rule doesn't fire on a click , there is likely an issue with the selector or condition of the rule. Locate the element on your site where the desired event action occurs, right click and select Inspect element. Inspect the highlighted script in the box that opens and ensure you are targeting the correct element. Please let us know if you have any questions on this .
Answer to 2nd part of your question:
To define a data element on the fly and then use it in the interface for an event based rule, we can dynamically capture the value of the event, and can set it when defining the criteria for an event based rule, within the custom code block in rule conditions using below code:
var str= $(this).attr("href"); // This line will fetch the href of the download link clicked when an event click rule is fired on clicking of a link on the page. var str1= download file name // Use some standard javascript functionality to get the file name from the str variable and assign it to str1 variable. _satellite.setVar('Download_Link_Name',str1); _satellite.getVar('Download_Link_Name'); return true;
// This data element will now be available like any other within the interface using %Download_Link_Name%
Additional Points:
- setVar saves the data element on a page level scope – this is okay since you’ll typically only be manually setting these variables when you are referencing elements with $(this).
- You can also use %% substitutions for these data elements within the UI. For the example above, we could have referenced the data element via %link ID%.
- When you manually override a data element that exists and has a scope, it retains the scope of the element.
Please feel free to reach out to us in case of further queries.
Thanks & Regards
Parit Mittal