Data Element JS not working in DTM but works in console

Avatar

Avatar

DinoF40

Avatar

DinoF40

DinoF40

07-06-2017

Hi,

I'm hoping someone could help. I'm trying to get an on page JS variable into a DTM data element. The code works fine in Google Tag Manager and works in the dev console but is undefined in Adobe DTM.

This is what I'm using as the custom JS for the data element:

    var ips4_member_id = ipsSettings.memberID;

    return ips4_member_id;

The JS script on the HTML page is as follows and I'm trying to get the member ID:

<script type='text/javascript'>

   var ipsSettings = {

  disableNotificationSounds: false,

  useCompiledFiles: true,

  links_external: 1,

  memberID: 0,

  analyticsProvider: "custom",

   };

  </script>

Any help would be much appreciated.

Cheers

View Entire Topic

Avatar

Avatar

DinoF40

Avatar

DinoF40

DinoF40

08-06-2017

Well I thought it was working, in the console _satellite.getVar("ips4_member_id"); returns the correct value.

However when published I get the following error which prevents the whole DTM container from loading.

Uncaught ReferenceError: ipsSettings is not defined

    at Object.customJS (satelliteLib-dd4a7b2….js:12)

    at Object.D.realGetDataElement (satelliteLib-dd4a7b2….js:10)

    at Object.D.getDataElement (satelliteLib-dd4a7b2….js:10)

    at Object.D.getVar (satelliteLib-dd4a7b2….js:10)

    at satelliteLib-dd4a7b2….js:10

    at String.replace (<anonymous>)

    at Object.D.replace (satelliteLib-dd4a7b2….js:10)

    at g.parseIds (satelliteLib-dd4a7b2….js:11)

    at g.applyCustomerIDs (satelliteLib-dd4a7b2….js:11)

    at g.initialize (satelliteLib-dd4a7b2….js:11)