Z
Z
zorelenko2021-07-13 01:25:02
WordPress
zorelenko, 2021-07-13 01:25:02

How to write a value to a hidden field?

You need to write the value of " visitor_uid " to a hidden form field.

Where can I write the code below in Wordpress?
Functions.php , or in an html block on any Wordpress page?
How to correctly call this function to get the visitor_uid in the hidden form field?

<script type="text/javascript" id="amo_pixel_identifier_js" async="async"
        src="https://piper.amocrm.ru/pixel/js/identifier/pixel_identifier.js"></script>


window.AMOPIXEL_IDENTIFIER_PARAMS = window.AMOPIXEL_IDENTIFIER_PARAMS || { } ;
window.AMOPIXEL_IDENTIFIER_PARAMS.onload = function (pixel_identifier) {
    var visitor_uid = pixel_identifier.getVisitorUid ( ) ; // Получаем visitor_uid
    console.log ( 'visitor_uid' , visitor_uid) ;
    if (visitor_uid) {
      // Записываем его в скрытое поле формы 'visitor_uid'
      document.getElementById ( 'visitor_uid' ).value = visitor_uid;
   }
} ;


You can also specify a callback function by creating an AMOPIXEL_IDENTIFIER_PARAMS object, where the callback function will be indicated in the “onload” field.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aricus, 2021-07-13
@Aricus

It's illiterate to write this in functions. If it is needed on all pages, then in the footer, and if on a specific one, then at the end of this page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question