A
A
a16a2017-11-22 11:49:10
PHP
a16a, 2017-11-22 11:49:10

How to add utm tags to a deal?

Good day.
On the Amocrm service.
It is necessary to make sure that when sending an application, utm tags are also sent. I searched the internet and found these codes. But when I inserted them into my code, deals were not created at all. How can it be corrected or supplemented?

'source_data' => array(
  array(
      'id' => 'ID',
      'values' => array(
        array(
          'value' => $utm_source,
        )
      )
    ),
);

if (!empty($utm_source)) {
        $request["add"][0]["custom_fields"][] = array(
            "id" => 16533, // source
            "values" => array(
                array(
                    "value" => $utm_source
                )
            )
        );
  unset($utm_source);
    }

foreach($custom_fields_leads as $field){
                if($field['name']=='Источник трафика' && $utm_source != '')
                    $add['request']['leads']['add'][0]['custom_fields'][]=array('id'=>$field['id'],'values'=>array(array('value'=>$utm_source)));
                if($field['name']=='Тип трафика' && $utm_medium != '')
                    $add['request']['leads']['add'][0]['custom_fields'][]=array('id'=>$field['id'],'values'=>array(array('value'=>$utm_medium)));
                if($field['name']=='Название рекламной кампании' && $utm_campaign != '')
                    $add['request']['leads']['add'][0]['custom_fields'][]=array('id'=>$field['id'],'values'=>array(array('value'=>$utm_campaign)));
                if($field['name']=='Ключевое слово кампании' && $utm_term != '')
                    $add['request']['leads']['add'][0]['custom_fields'][]=array('id'=>$field['id'],'values'=>array(array('value'=>$utm_term)));
            }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
synapse_people, 2017-11-22
@synapse_people

https://github.com/dotzero/amocrm-php
Use this solution, there is such an option

P
Pavel Kupreev, 2018-08-03
@start-crm

We save the tags in cookies on the first visit
. Then we pass them to the fields via custom_fields

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question