Expand my Community achievements bar.

SOLVED

DTM - How do I access a hidden field within a Page Load Rule

Avatar

Level 2

1.    I created a new Page Load Rule.

2.    The conditions on the page are
    a.    Trigger rule at DOM Ready
    b.    And only fire when dataelement OrderId is numeric
3.    I created a Non-Sequential HTML script in the Javascript / Third Party tags section –
4.    I have two variables I want to alter on the page
    a.    fb_param.value = %SubTotal%;  ==== This works fine as this is a javascript variable on the page.
    b.    fb_param.currency = 'USD';   === This does not work as you can see it is hardcoded as USD but I want it to be dynamic.

So here is the question:
        For fb_param.currency = 'USD';    I want the ‘USD’ to be dynamic on the page based on an asp:hiddenfield on the source.  Everything I try to access this hidden field variable doesn’t seem to work the way I think it should.
        <input type='hidden' name='satlCurrencyType' id='satlCurrencyType' value='USD' />

I have created a dataElement for it called CurrencyType

I have tried to access the variable with jQuery  ::: $(“#satlCurrencyType”).val();
I have tried to access the variable the same way as %SubTotal% with %CurrencyType%  -- This gives me a javascript error of Reference Error : USD is not defined. So, it finds the dataElement, but it seems to think it is a reference to something else?

I have tried to access the variable as _satellite.getVar('CurrencyType')

I see the object in the DOM : _satellite.dataElements.CurrencyType.

Plus, many other different ways that I thought should work. But, it always gives me an error of some kind.

I just don’t know the best way to access it in Dynamic Tag Management.

Any thoughts?

1 Accepted Solution

Avatar

Correct answer by
Level 2

Okay, I have figured it out, but it wasn't intuitive. I had a variable, %CurrencyType% which is a string value. I was trying to put it into fb_param.currency = %CurrencyType%.

I kept getting an error message USD is not defined. So, it was seeing the CurrencyType but it didn't know what to do with it.

I changed it to fb_param.currency = '%CurrencyType%'

So, adding the quote marks solved the problem. Wow, I didn't see that coming. So, we can put quote marks around a variable. From a programmer's perspective that isn't intuitive at all.

But, I guess it doesn't matter too much since no one appears to be moderating these forums anyway.

View solution in original post

3 Replies

Avatar

Correct answer by
Level 2

Okay, I have figured it out, but it wasn't intuitive. I had a variable, %CurrencyType% which is a string value. I was trying to put it into fb_param.currency = %CurrencyType%.

I kept getting an error message USD is not defined. So, it was seeing the CurrencyType but it didn't know what to do with it.

I changed it to fb_param.currency = '%CurrencyType%'

So, adding the quote marks solved the problem. Wow, I didn't see that coming. So, we can put quote marks around a variable. From a programmer's perspective that isn't intuitive at all.

But, I guess it doesn't matter too much since no one appears to be moderating these forums anyway.

Avatar

Employee

Ken,

Sorry for the delay in response here.  I am surprised that  _satellite.getVar('CurrencyType') did not get the value for you.  I'll send this to the product team to make them aware.

 

-Rudi

Avatar

Level 2

Thanks, Rudi! That will help a lot.

Now that I have a better understanding of the Satellite tool, I am navigating and creating rules and conditions using the created Data Elements.