Jump to content
Search Community

GTM with Wordpress issues

BONOMITE test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

So I have been experiencing some issue with GTM (Google Tag Manager). I was working on a Wordpress site... and I noticed that this error started to show up "Uncaught TypeError: Cannot create property 'greensock' on string 'firstname|lastname|username|email|emailaddress|ssn'" .

 

After pulling my hair out... I was able to fix the issue by moving down the GTM script to the very bottom of the head.

 

So now, I have another project. wordpress as well... and a developer is seeing the same issue... but ONLY in "gtm preview mode" . Any thoughts?

 

-Thomas

Link to comment
Share on other sites

It sounds like there must be a "com" object defined in the global space that's not an object. For convenience, GSAP puts all of its classes in the reverse-domain standard of com.greensock (example: com.greensock.TweenMax, and com.greensock.easing.Power2). In other words, there must be something else that's declared "com" as something else like:

 

var com = 'firstname|lastname|username|email|emailaddress|ssn'; 

 

So when GSAP tries to add "greensock" to that object, it's throwing an error.

 

Possible solutions: 

  1. Name that variable differently (anything but "com"). 
  2. -OR- try declaring a GreenSockGlobals object before loading GSAP, like var GreenSockGlobals = {}; because GSAP looks for that and if it finds one declared, that's where it'll dump everything. 
  3. -OR- Right before loading GSAP, re-declare that variable as something else, like com = {};. This assumes you don't need that old com stuff after that point. You could always store it in a different variable, redeclare it, load GSAP, and re-assign it back to the "com" variable after that (I doubt you'll need to do that). 

Hope that helps. 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...