In this section, we will share how to publish custom code. This code cannot be implemented through Extensions. Suppose we are deploying the global tracking code of Google Analytics here, the code is as follows:
<span style="font-size: 12pt;"><!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-69988360-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-69988360-1'); </script> </span>
Libraries are the JavaScript files that load on the page to do all of the work. This section is mainly to understand the Libraries deployment logic, Library configuration is mainly through Extensions, Data Elements and Rules:
- Extensions are basically apps or plugins that can be used to enhance your Launch experience,It can simplify code deployment and configuration.
- Data Elements store the attributes you want to send to your marketing and advertising solutions, which are mostly used in Adobe Launch rules, but can also be used in Extensions
- Rules fire the requests to those solutions under the right conditions.
Here, we do not need to use Extensions and Data Elements, we only need to use Rules to implement the deployment of custom code.
Create New Rules
In the top navigation, click Rules and then click “Add Rule”:
Then you will see such an interface. This is the rule setting interface. The role of the rule is to perform any operation when the conditions are met, similar to If … then …
- Name the Rule All Pages – Library Loaded . This naming convention indicates where and when the rule will fire, making it easier to identify and re-use as your Launch property matures.
- IF – Determines when you want the rule to fire, if includes events and conditions, EVENTS are mandatory things that must occur before a rule will fire; CONDITIONS are options checks again the state of environments to further restrict the rule.
- THEN – Determines what you want the rule to do, Only ACTIONS.
Set EVENTS
Under Events, click Add . The Event tells Launch when the rule should fire and can be many things, including a page load, a click, a custom JavaScript event, etc.
As the Event Type, select Library Loaded (Page Top) . Note that when you select the Event Type, Launch pre-populates a name for the event using your selection. Also note that the default order for the event is 50. Ordering is a powerful feature in Launch which gives you precise control over the sequence of actions when you have multiple rules that are triggered by the same event. You will use this feature later in the tutorial.The configured effect is as follows:
Click the Keep Changes button.
Set ACTIONS
Since this rule should fire on all pages, leave Conditions blank. Under Actions, click Add: