You have Google Tag Manager installed on your website, but you also want to use Yandex.Metrica to track conversion goals there, e.g. for custom reports or Yandex.Direct campaign .
In this article I will describe how to do it, using the example of tracking the form submission on my blog.
There are four steps of how to integrate Yandex.Metrica into Google Tag Manager:
- Create a conversion goal in Yandex.Metrica
- Add Yandex.Metrica code in GTM
- Create a trigger for form submission
- Create a tag to send the conversion to Yandex.Metrica
I guess you already have the account in Yandex.Metrica, so now at first let’s create a conversion goal for form submission. Go to Settings page, click Goals tab and then click Add goal.
Click Add goal and then Save at the bottom.
Now we should create the main GTM tag for Yandex.Metrica to allow it collect the data through your GTM container. Again, go to Metrica settings page, choose Counter code tab and copy your code to clipboard.
Next, go to your GTM account, and in the Tags section click New.
In the Tag Configuration select Custom HTML and here paste your Metrica tracking code:
Then, in the Triggering tab choose All pages and save. Now your tag will collect all pageviews and send the data to your Metrica account.
Now we should create a trigger to make GTM understand that a specific form is being submitted. First, go to your form on the website and open the source code to see its ID. In my case the ID is
wpforms-form-4124 (click to enlarge)
Now let’s create the trigger in GTM. Go to Triggers section and select New.
In the Trigger Configuration select Form Submission, and then select the condition
Form ID equals, and in the last field paste your form ID:
Name your trigger, for example, “YM Form submit” and save.
Again open the Tags section, click New.
Here at the bottom choose the trigger that we’ve just created. And in the Tag Configuration select Custom HTML and paste the following code:
where instead of XXXXXXXX you need to insert your Metrica account number. You’ll find it right next to your account name:
And instead of GOAL-NAME insert the name of the goal you’ve created in Metrica. Don’t forget the single quotation marks! Your should have something like this:
OK, name your new tag, for example “YMtag – Form submit”, save, and test if everything works.
Keep in mind that Yandex.Metrica does not have real-time statistics yet, so the conversion may appear with a delay of a few minutes.