New JS file vs Included within Embed Code

Avatar

Avatar

SarahEOwen

Avatar

SarahEOwen

SarahEOwen

05-09-2017

Can we discuss when a piece of code will create its own js script versus when it will be combined within the Launch embed code?

Here's a scenario we can use for this discussion:

1. I enabled the Facebook extension

2. I went to the Rules tab and opened my existing "All Pages - DOM Ready - Pixels" rule

3. I scrolled down to the "Then" portion of the rule and clicked the + icon

4. I selected the Facebook Pixel extension and the "Send Page View" action. I kept the default name of "Facebook Pixel - Send Page View" (see screen shot 1 below)

5. I went through the process of getting the changes to Stage. Stage is test1.hmkb2c.com for me

6. Looking at the Elements tab in Developers' Tools, I see that the FB pixel appears to be added to my Embed Code js (see screen shot 2 below)

7. I expected that the FB pixel would have made another js file - just like the other 2 rules in the "All Pages - DOM Ready - Pixels" rule (see screen shot 3 below).

I would just like to be educated on where to expect and look for rules

Screen Shot 1 :: Added FB pixel to existing Rule

1293005_pastedImage_0.png

Screen Shot 2 :: Launch Embed Code

1293008_pastedImage_3.png

Screen Shot 3 :: Other JS files injected by Launch

1293010_pastedImage_4.png

Thanks -

Sarah

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Aaronius9er9er9

Employee

Avatar

Aaronius9er9er9

Employee

Aaronius9er9er9
Employee

08-09-2017

Hi Sarah. What gets embedded in the library vs loaded as separate files is largely left up to the extension. In the case of Facebook, there's really two parts. One part is the extension "action" code that Launch runs when a rule is fired. The action code then calls, for example, fbq('track', 'PageView');. The logic behind the fbq function that actually sends the request to the server, etc. is loaded in dynamically as a separate file. If you search your network tab for fbevents on http://test1.hmkb2c.com/ you'll see that file being loaded in. In other words, the code that's embedded in the Launch library is basically just glue between Launch and the fbevents library that gets loaded in.

Technically, Facebook could opt into embedding the fbevents.js code into the Launch library instead of loading it as a separate file. It's their choice.

In the case of the Core extension's Custom Code action, the custom code is embedded in the Launch library if it pertains to a rule that has a Page Top or Page Bottom event, otherwise it's split into a separate file.

Answers (2)

Answers (2)

Avatar

Avatar

thebenrobb

Employee

Avatar

thebenrobb

Employee

thebenrobb
Employee

07-09-2017

I'm going to need Aaronius9er9er9er to weigh in here for the real answer.  I believe that any custom code blocks will show up as secondary .js files linked to the main .js file.  Also, any libraries that are referenced (appmeasurement.js, at.js, etc) will obviously come separately - though they aren't linked in the same way that the ones coming from Launch are.

Avatar

Avatar

SarahEOwen

Avatar

SarahEOwen

SarahEOwen

08-09-2017

Thank you so much, @thebenrobb and @Aaronius9er9er9er, for the replies. You both always provide answers that are understandable!

I really appreciate you, @Aaronius9er9er9er, explaining the Facebook example - the last sentence the references glue really helped solidify the relationship for me. And thank you for calling out when the Core extension makes separate file vs including it in the embed code!

Thanks -

Sarah