bsg
December 30, 2022, 12:12am
1
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.
Apple
December 30, 2022, 12:39am
2
Try:
var pixels = dmx.parse('content.mypixels.value');
1 Like
bsg
December 30, 2022, 12:57am
3
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?
JonL
December 30, 2022, 1:06am
4
This is quite a bad practice. But if you insist you have JS eval() function.
1 Like
bsg
December 30, 2022, 1:14am
5
I understand, as I commented earlier, do you know how to insert a complete script through dmx?
JonL
December 30, 2022, 1:29am
6
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
bsg
December 30, 2022, 1:32am
7
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.
JonL
December 30, 2022, 1:45am
8
If you are using nodejs you can inject the code at server parsing time by using EJS templating.
1 Like
bsg
December 30, 2022, 1:53am
11
Understood!! Thanks my friend.
bsg
December 30, 2022, 2:34am
13
This one is not very useful, it has to be something that imports the complete script from the database.
bsg
December 30, 2022, 2:36am
14
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.
JonL
December 30, 2022, 3:27am
15
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.