最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - DTM: _satellite not defined - Stack Overflow

programmeradmin0浏览0评论

I'm using a Non-Sequential HTML Javascript/Third Party tag, where I'm using the following script to pass data to a 3rd party tag.

<script>
   x = _satellite.getVar('Sub-Total');
</script>

The problem that I have is that no data is passed to "x".

I have also tried the following:

<script>
   var x = $('td[data-hook="order_item_total"]').text().substring(1);
</script>

In this case I'm getting $ is undefined. Note, both methods work when I test it in the Javascript console and if I use a Non-Sequential Javascript tag. What do I need to add to make either of these work? Your help is greatly appreciated.

Thanks,

Ridder

I'm using a Non-Sequential HTML Javascript/Third Party tag, where I'm using the following script to pass data to a 3rd party tag.

<script>
   x = _satellite.getVar('Sub-Total');
</script>

The problem that I have is that no data is passed to "x".

I have also tried the following:

<script>
   var x = $('td[data-hook="order_item_total"]').text().substring(1);
</script>

In this case I'm getting $ is undefined. Note, both methods work when I test it in the Javascript console and if I use a Non-Sequential Javascript tag. What do I need to add to make either of these work? Your help is greatly appreciated.

Thanks,

Ridder

Share Improve this question asked Feb 7, 2015 at 6:11 RidderRidder 1121 gold badge1 silver badge6 bronze badges 3
  • So are you getting a _satellite not defined error, or is it just returning undefined on the data element call? Do you have the data element ("Sub-Total") setup / have a value set to it? For the second part, do you have jQuery included before the DTM script include? – MisterPhilip Commented Feb 7, 2015 at 20:31
  • @MisterPhilip - To answer your questions: I'm getting a "_satellite not defined error". I have a data element ("Sub-Total") and it returns a value. I have tried including jQuery before the DTM, as well as changing $ for jQuery in the statement. – Ridder Commented Feb 8, 2015 at 7:32
  • So you're getting a _satellite not defined error from code that originates from a tag in DTM? Are there any other errors on the page? What does setting DTM into debug mode show (run _satellite.setDebug(true) and reload the page to see console output)? Do other rules get loaded? – MisterPhilip Commented Feb 9, 2015 at 4:20
Add a ment  | 

1 Answer 1

Reset to default 5

The issue is when you configure your tag to be Non-Sequential HTML, the code is output dynamically in an iframe. Since the iframe doesn't include the _satellite object, attempting to reference it results in an undefined error.

If your tag contains a blend of html and javascript that needs to be output and you need _satellite exposed, you need to instead use a Sequential HTML tag.

Alternatively, if the code in your tag is really purely javascript and just happens to be wrapped in <script> tags, then simply remove the <script> tag wrapper and put the code in a Javacript style tag (It doesn't matter if it's sequential or non-sequential; both will have _satellite exposed to it) .

Note: I could find no mention of this in the DTM documentation (though I could be blind!), but If you open your browser's developer console and look at the live/rendered DOM, you can verify this yourself. I feel like at a minimum this caveat should at least be mentioned in the documentation.

发布评论

评论列表(0)

  1. 暂无评论