Google Tag Manager: we track referrals to affiliate links. Encyclopedia of Internet Marketing: What is Google Tag Manager and how to use it Installing google tag manager

Good afternoon, readers and guests. In this article we will learn how to configure Google Tag Manager to track referrals to affiliate links in Yandex Metrica and Google Analytics.

The idea of ​​writing arose due to the fact that I installed a banner on my blog with an affiliate link that leads to hosting. And I became interested in which of the visitors to my site clicked on this link, i.e. I wanted to set up goals in Yandex Metrica and Google Analytics so that they reflected the transition from the banner.

On my blog, analytics is installed through Google Tag Manager (Google Tag Manager or GTM). In search of clues about what appropriate settings need to be made in GTM, I scoured the entire RuNet, but I never found an answer. And I found it from an American - his name is Julian Juenemann. Unfortunately, the resource https://measureschool.com, which the author refers to at the moment unavailable.

Google Tag Manager - what is it??

I don’t think it’s necessary to talk in detail about what Google Tag Manager is in this article. There is enough relevant material on this topic on the Internet.

But if we talk in simple language, then GTM can be thought of as a kind of container, a kind of container that we install on our website in the form of HTML code. And in this container we can put anything we want. For example, install a counter for any statistics, be it Yandex Metrica or Google Analytics, etc. Set up conversion tracking, transition tracking, and much more.

The “thing” is very convenient, especially if you are working with a client service that you do not have access to via FTP. It’s enough to ask the programmer once to install this container on the site and then torment your colleague with your own technical specifications No need. And don’t waste several days waiting for him to finally do the job, as has happened more than once in my practice. I don’t want to offend programmers, they are busy people and you also need to understand them. But, time is money!

The practical part. How to track referrals to affiliate links. Setting it up Google Tag Manager.

To demonstrate the settings, I created a test site on which I installed a banner that leads to the partner’s site. We will set up tracking of transitions on the bottom banner using Google Tag Manager. We will see transitions in Yandex Metrica and Google Analytics.

Setting up a trigger to track all clicks

This action will allow us to track all clicks made on the site without exception.

  • In the Google Tag Manager interface, go to the “Triggers” tab.
  • Trigger type - “Links only”.
  • The trigger is activated on all pages: “All link clicks.”
  • We write a name, for example “Click on links”.
  • Rice. 1

    We set up a trigger to track transitions to a specific link, in our case, an affiliate link
  • Once again go to the tab - “Triggers".
  • Trigger type - “Clicks only”.
  • Next, select the “Wait for tags” and “Error checking” checkboxes.
  • We set the conditions under which our trigger will be activated. First, we indicate the path (domain) of our site - the trigger will fire on all pages of the site. The second condition is that our trigger will be activated only when you click on a specific link, i.e. an affiliate link. See Fig. 2.
  • Rice. 2

    Setting up Google Tag Manager to track events in Google Analytics

    We configure the “Tag” tool so that the completed action - clicking on an affiliate link - is displayed in Google Analytics. The GA code should already be installed on your resource.

  • Tag type - Universal Analytics.
  • Tracking type - "Event".
  • Parameters of tracked events: “Category” - for example, Affiliate Links; “Action” - Click URL; "Shortcut" - Page Path.
  • IN Google settings Analytics by specifying a tracking identifier (GA code).
  • And lastly, add the previously created “Click on Banner” trigger. See Fig. 3.
  • Rice. 3

    All that remains is to publish the settings for them to take effect. Our result is the ability to track conversions made through affiliate links in Google Analytics. And if we now click on the partner’s posted banner, the corresponding event will be displayed in Analytics. See fig. 4.

    Rice. 4

    I decided to write how to set up Google Tag Manager to track conversions in Yandex Metrica in the second part of the article - “Google Tag Manager: tracking conversions via affiliate links. Part 2". To dispel all the questions you have about setting up, I recorded a corresponding video for you. A small bonus awaits you in the video - I showed how to set up a goal for our event in Google Analytics.

    Yulia Khairetdinova was with you

    Google Tag Manager lets you customize and deploy tags, including those for Google Ads, Google Analytics, and Floodlight, as well as third-party tags. To use Tag Manager, follow these steps:

    An account is the highest level of hierarchy in Tag Manager. As a rule, one account is enough for a company. Your Tag Manager account has one or more containers. There are types of containers for websites, AMP pages, Android applications and iOS.

    How to create an account and container

    When you first load a container, you'll be prompted to add a code snippet to your site or get started with Tag Manager within the SDK for your chosen platform. You can snippet the code right away or click OK to do it after setting up the container.

    How to add a container to an existing account Installing a container

    Web pages

    • Place the top code snippet (starting with ) in a section of the web page. It is advisable to do this as close to the opening tag as possible, but after the dataLayer declarations.
    • Place the bottom code snippet (starting with ) immediately after the tag.

    To prevent reactivation, remove any manual tags from your code that were moved to the Tag Manager container.

    To prevent unauthorized access to the container, the Tag Manager code snippet uses HTTPS by default.

    We present to your attention step by step instructions on installing and configuring Google Tag Manager (GTM). Here we will tell you how to connect Google Analytics and Yandex Metrica using GTM.

    Google Tag Manager (GTM) – multifunctional tool, which allows you to add to a site or mobile application tags for analyzing traffic, conversion and user behavior without interfering with source code site.

    In this article we will describe in detail how to create and configure GTM on a website and how to connect Google Analytics and Yandex Metrica without interfering with the site’s source code.

    Benefits of GTM
    • You can add and update tags without interfering with the site's source code. You only need to add the Tag Manager code to the site once, and everything else can be implemented in personal account GTM;
    • Reducing code on website pages;
    • Convenient and easy to use interface;
    • Ease of testing. Mode preview allows marketers to easily check whether tags are working correctly;
    • The service is free.

    Before moving on to installation, let's look at the definitions:

    • Container is a fragment of JS code that is placed on all pages of the site. The container contains information about tags that are fired as a result of the execution of certain rules specified in triggers and variables;
    • Tag– a fragment of site code that allows you to track traffic and analyze user behavior, conversion, etc. (for example, Yandex Metrics code);
    • determine when to activate the tag in the web container;
    • Variables is a name-value pair that is used in a trigger as a condition under which the tag will fire.
    How to install Google Tag Manager on a website

    1. Register an account with Google

    If you already have a Google account and are signed in, skip this step. If not, log in or create an account.

    2. Create an account in GTM

    After logging in to Google, you can proceed to creating an account in GTM. Go to the Google Tag Manager page and click on the “Create an account” button, then enter a fictitious account name and click on the “Next” button.

    Figure 1

    In the window that appears, enter an invented name for the container and select where it will be used. In our case, this is the “Website” button. After that, click on the “Create” button.

    Figure 2

    Figure 3


    3. Add the resulting Tag Manager code to your site

    Once you accept the usage agreement, a code window will appear.

    Figure 4

    Select and copy the code to txt file. After that, click on the “OK” button at the very bottom of the window that opens.
    Next, in the site template file in which you have the block, insert the code from the top block as close to the beginning as possible.

    Figure 5

    Paste the code from the bottom block directly after the opening tag.

    Figure 6

    After you complete these steps, click on the “Publish” button in the GTM panel.

    Figure 7


    4. Test the correct operation of GTM

    Next, it is important to check whether you did everything correctly. To do this, you can use the Google Tag Assistant Recordings plugin for Chrome browser. Install this extension by following the link.

    After installation, the Google Tag Assistant icon will appear in the Chrome browser extensions panel - . To check that GTM installed on your website is working correctly, you need to go to your website and click on this icon.

    Figure 8

    From the screenshot we see that the icon green, this means that the installation of Tag Manager was successful. If the icon is yellow or red, the tag is placed with errors.
    Google Recommendations

    Figure 9

    Connecting Google Analytics via GTM

    Now let's proceed directly to connecting Google Analytics via GTM.


    1. Register Google Analytics

    If analytics are already installed on the site, you can skip this point. If not, check out how to register Google.Analytics and complete the registration process.

    Pay attention! After registering Google.Analytics, you do not need to place the code on the site. We'll only need the Google.Analytics tracking ID a little later. If Google.Analytics was registered earlier and the code is already posted on the site, after connecting Google.Analytics via GTM, the previously posted analytics code can be removed.


    2. Log in to your previously registered GTM account and click on the “Add” link new tag»

    Figure 10


    3. Select tag type

    In this case, we need Universal Analytics.

    Figure 11


    4. Specify the site's Google Analytics tracking ID and tracking type - “Page View”

    Figure 12

    You can view the resource tracking ID in your Google Analytics settings.

    Figure 13

    5. Specify the “All Pages” trigger

    To make the tag fire on all pages, specify the “All Pages” trigger.

    Figure 14


    6. Save the entered data

    Figure 15


    7. Specify the tag name and click on the “Save” button

    Figure 16


    8. Check if the tag is working correctly

    To do this, click on the arrow next to the “Publish” button and select “Preview”.

    Figure 17

    In Preview, the container with changes will only be available in your browser.

    If the container appeared under the line "Tags Not Fired On This Page", the tag on the page did not fire. It is necessary to check all settings and, if necessary, correct any errors.

    If the container appears under the line “Tags Fired On This Page,” it means that Universal Analytics was installed without errors.

    Figure 18


    9. Publish Universal Analytics

    Figure 19

    Thus, we connected Google Analytics to the site via GTM without interfering with the source code of the pages.

    Connecting Yandex Metrics via GTM

    To connect Yandex Metrics, follow the same steps as for Google Analytics, but since by default there is no Yandex Metrics in GTM, when selecting a product, specify “custom HTML”.

    Figure 20

    As a result, a window with an empty field will appear.

    Figure 21

    You must insert the code for your Metrica counter into this HTML form.

    If Yandex Metrica is already installed on the site, copy the counter code from the page source code. If not, read how to create and configure a Yandex Metrics counter.

    Pay attention! As with Google.Analytics, there is no need to place code on the site. When setting up Yandex Metrica, the resulting code must be copied and added to the “Custom HTML” window that appeared at the previous stage.

    Figure 22

    Before publishing, check that the tag is working correctly by clicking on the “Preview” button.

    Figure 23

    If in preview mode the container is placed under the line “Tags Fired On This Page”, then everything is configured correctly. If the container is displayed under the line “Tags Not Fired On This Page”, the tag did not work, most likely an error was made during connection.

    Figure 24

    After we are convinced that the tag worked in preliminary mode, click “Publish”.

    Thus, we connected Yandex Metrica to the site without interfering with the source code of the pages.

    If you don't already have GTM installed on your site, you can install and configure it by following our instructions. And we, in turn, will continue to write about how to analyze traffic, conversions and user behavior using GTM.

    Greetings everyone! Today we will talk about google tag manager and see how you can customize using this tool. Google tag manager allows you to quickly update tags and code snippets on your website or app. To put it simply, you can configure when and what information you want to send, for example, to google analytics.

    First, let's look at the interface. Follow the link: https://www.google.ru/tagmanager/

    Name the container, select a website, click “create”. Next, we accept the terms of use agreement for the tag manager. After this, we immediately see instructions for installing the code, but if you did not install the code right away, then you can find it later in the “administration” tab:

    The workspace also has 5 tabs on the left:

    • review
    • tags
    • triggers
    • variables
    • folders

    Now let's look at them in order. When we go to the “workspace” we get to the “overview” tab, which contains general information about our container. In the tags tab we will configure what information we want to send. The triggers tab allows you to set rules that will determine when our tag should fire. In the variables tab we will set what parameters we want to track. Well, the folder tab is needed for convenient grouping of created tags, triggers and variables.

    Installing Google Analytics code on the site

    The capabilities of a tag manager are quite extensive, but in this article we will consider only simple tasks. To get started, we'll simply install the google analytics code on our site. To do this, go to the tags tab and click the “create” button, come up with a name for our tag, and select the Universal Analytics code from the drop-down menu.

    Add the tracking ID and leave the rest of the settings as they are.

    Then we move on to selecting a trigger. Because We have not created new rules yet; we will only have 1 available trigger “all pages”, select it and click “save” in the upper right corner. After creation, we definitely need to check how the tag we created works. To do this, we click on the arrow next to the “publish” button and select “preview” from the drop-down menu.

    Now we need (necessarily in the same browser) to open our website. At the bottom of the screen we should see the google tag manager panel.

    The screenshot shows that our code worked correctly. Those. When the page loaded, visit data was sent to analytics. Once we've checked that our tag is working correctly, we need to exit preview mode and publish the changes.

    Setting Bounce Rate in Google Tag Manager

    Now that we have installed the analytics code on the site, let's configure it. Just in case, let me remind you that by default, a refusal for analytics is any visit in which there was no transition to another page of the site or some event was not recorded. However, the time spent on the site does not affect this indicator in any way. For comparison, in Yandex, a visit lasting less than 15 seconds, without transitions and useful actions, is considered a refusal. Now we'll look at how to quickly set up your bounce rate with using google tag manager. To do this, we need to configure sending an event to Google Analytics after a certain time has passed (let’s say it’s 15 seconds). First, let's create a trigger. Go to the triggers tab and click the “create” button, then come up with a name for the trigger and select the type - timer.

    Now we need to set the interval to 15000 (since these are milliseconds), set the limit to 1 (how many times a goal can be recorded per visit). In the trigger condition we set Page url, “contains” and the domain of our site. Select “all timers” so that the trigger fires on all pages.

    Click “save” and go to the tags tab. We create a Universal Analytics tag, come up with a name, add a tracking ID, and select the tracking type - “event”. Next, fill out the “category” and “action”; you can do this arbitrarily because we will not use this data, we need the fact of sending the data. Then, the “no interaction” item must be set to “false”.

    After that, from the list of triggers, select the one we created and click save.

    We have a new tag ready and we need to test it again. Go to preview mode, go to the site, wait 15 seconds. As a result, we should see 2 tags.

    We return to the tag manager, exit the preview mode and publish the update. All update versions are saved in the tag manager and, if necessary, you can roll back to the previous version. I think that this information is enough to get started with the tag manager. Good luck!

    Share