Expand my Community achievements bar.

SOLVED

"$ is not defined" Error in Custom Event Code

Avatar

Level 10

I am getting an error in my Custom Event Code saying that "$ is not defined"   Below are steps to put in a break point to see the jquery error as well as steps on where to find the Custom Event Code within my web property in Launch.

Put in a break point to see the jquery error:

1) go to test1.hmkb2c.com

2) open Developers' Tools and go to the Sources tab

3) on the left side of the Sources tab expand assets.adobedtm.com and double click on the file that starts launch-EN

4) the file will open on the right. click on the pretty print icon at the bottom left of this area

5) search for olapic

6) put a break point on the "$(document.ready(function() {" line of code, which is a few lines above the first instance of olapic (see yellow highlighting in the screen shot below)

   1321646_pastedImage_6.png

7) refresh the web page

8) the break point will be hit - you may need to click the step-over arrow three times to get to the error (see screen shot below)

    1321647_pastedImage_8.png

Here is the location of the jquery that is erroring out:

1) go to my Launch instance

2) click on the test1 Web Property

3) click on the Rules tab and click on "Page Bottom - All Pages - Analytics :: Send s.t() beacon"

4) in the "Events" section of the Rule, click on the "UGC Content Loaded" portion (see screen shot below)

      1321644_pastedImage_3.png    

5) The jquery in this custom event code is what is erroring out on the website.

          1321645_pastedImage_4.png

Thanks -

Sarah

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi SarahEOwen​,

This is happening because jQuery is loaded after the Launch library. If you take a look at your html (right-click the page and hit View Page Source), you'll see this:

<script src="//assets.adobedtm.com/launch-EN5ab8752a1e4148439580ebea683c2d42.js"></script>

<link rel="stylesheet" media="all" href="https://forums.adobe.com//contenttest1.hmkb2c.com/assets/styles/core-w-header-and-footer.css" >

<link type="text/css" href="https://forums.adobe.com//contenttest1.hmkb2c.com/assets/styles/home-page.css" rel="stylesheet">

<script type="text/javascript" src="//contenttest1.hmkb2c.com/assets/scripts/libs/require.js"></script>

<script type="text/javascript" src="//contenttest1.hmkb2c.com/assets/scripts/libs/jquery.js"></script>

Notice that jQuery gets loaded after the Launch library. Once you change the order, your problem should go away.

View solution in original post

3 Replies

Avatar

Correct answer by
Employee

Hi SarahEOwen​,

This is happening because jQuery is loaded after the Launch library. If you take a look at your html (right-click the page and hit View Page Source), you'll see this:

<script src="//assets.adobedtm.com/launch-EN5ab8752a1e4148439580ebea683c2d42.js"></script>

<link rel="stylesheet" media="all" href="https://forums.adobe.com//contenttest1.hmkb2c.com/assets/styles/core-w-header-and-footer.css" >

<link type="text/css" href="https://forums.adobe.com//contenttest1.hmkb2c.com/assets/styles/home-page.css" rel="stylesheet">

<script type="text/javascript" src="//contenttest1.hmkb2c.com/assets/scripts/libs/require.js"></script>

<script type="text/javascript" src="//contenttest1.hmkb2c.com/assets/scripts/libs/jquery.js"></script>

Notice that jQuery gets loaded after the Launch library. Once you change the order, your problem should go away.

Avatar

Level 10

LoL - this HAS to be the first time that DTM/Launch has ever been included too high on the page!!

Thanks so much for realizing this and pointing it out so gently to me, Aaronius9er9er9er​ !