Dmx.parse not working on var function and not run the console.log

Hi guys, i have the problem.

I need insert the meta tag facebook script on my website, so, need inside with dynamic function.

i used the begin script.

check this:

<dmx-value id="mypixels" dmx-bind:value="sc_checkfbpixels.data.fbpixels[0].pixelID"></dmx-value>

    <!-- Meta Pixel Code -->

    <script>

        function myFunction() {

        var pixels = dmx.parse('mypixels.value');

        console.log(pixels);

        }

        

    </script>

    <!-- End Meta Pixel Code -->`Preformatted text`

I need help, thanks for much.

Try:

var pixels = dmx.parse('content.mypixels.value');
1 Like

It worked without the “content”…

What I’m trying to do is:

Insert a script made in the header. Pulling this script from the database. I tried with dmx-text and it didn’t work because it messed up the script by inserting
. I tried with dmx-value and it didn’t work.

Do you have any tips?

This is quite a bad practice. But if you insist you have JS eval() function.

1 Like

I understand, as I commented earlier, do you know how to insert a complete script through dmx?

dmx is just the namespace for App Connect. What do you mean with

What do you have in your database exactly? A fb pixel number that you need to inject into a script or actual js code?

1 Like

I have the complete script.

<script> facbook pixel </script>

I want to inject it into the header dynamically. ex, I pull all the scripts that are in the selected bank.

If you are using nodejs you can inject the code at server parsing time by using EJS templating.

1 Like

How to make this?

And

1 Like

Understood!! Thanks my friend.

Check this also.

This one is not very useful, it has to be something that imports the complete script from the database.

I tried too but it didn’t work. Unfortunately I have to insert with a dmx, I just don’t know which one. Because the code must be loaded on the page.

Then import the complete script. There is no limitation on what you inject via EJS as it’s added before the webpage is rendered in the browser.