"$ is not defined" Error in Custom Event Code

Avatar

Avatar
Validate 50
Level 8
SarahEOwen
Level 8

Likes

269 likes

Total Posts

408 posts

Correct reply

17 solutions
Top badges earned
Validate 50
Validate 25
Validate 10
Validate 1
Ignite 1
View profile

Avatar
Validate 50
Level 8
SarahEOwen
Level 8

Likes

269 likes

Total Posts

408 posts

Correct reply

17 solutions
Top badges earned
Validate 50
Validate 25
Validate 10
Validate 1
Ignite 1
View profile
SarahEOwen
Level 8

10-10-2017

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

😎 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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 5
Employee
Aaronius9er9er9
Employee

Likes

34 likes

Total Posts

44 posts

Correct reply

16 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile

Avatar
Boost 5
Employee
Aaronius9er9er9
Employee

Likes

34 likes

Total Posts

44 posts

Correct reply

16 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile
Aaronius9er9er9
Employee

18-10-2017

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.

Answers (2)

Answers (2)

Avatar

Avatar
Validate 50
Level 8
SarahEOwen
Level 8

Likes

269 likes

Total Posts

408 posts

Correct reply

17 solutions
Top badges earned
Validate 50
Validate 25
Validate 10
Validate 1
Ignite 1
View profile

Avatar
Validate 50
Level 8
SarahEOwen
Level 8

Likes

269 likes

Total Posts

408 posts

Correct reply

17 solutions
Top badges earned
Validate 50
Validate 25
Validate 10
Validate 1
Ignite 1
View profile
SarahEOwen
Level 8

18-10-2017

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​ !

Avatar

Avatar
Contributor
Employee
thebenrobb
Employee

Likes

145 likes

Total Posts

318 posts

Correct reply

83 solutions
Top badges earned
Contributor
Seeker
Shape 1
Give Back 3
Give Back
View profile

Avatar
Contributor
Employee
thebenrobb
Employee

Likes

145 likes

Total Posts

318 posts

Correct reply

83 solutions
Top badges earned
Contributor
Seeker
Shape 1
Give Back 3
Give Back
View profile
thebenrobb
Employee

17-10-2017

Aaronius9er9er9er, can you provide some guidance?