# A Piwik method to mimik dataLayer.get(“gtm.element”)

**URL:** <https://community.piwik.pro/t/a-piwik-method-to-mimik-datalayer-get-gtm-element/3913>\
**Category:** Data collection and tags\
**Created:** [April 18, 2024, 2:45pm UTC](https://community.piwik.pro/t/a-piwik-method-to-mimik-datalayer-get-gtm-element/3913 "2024-04-18T14:45:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Martin](https://community.piwik.pro/u/Martin)\
**Post date:** [April 18, 2024, 2:45pm UTC](https://community.piwik.pro/t/a-piwik-method-to-mimik-datalayer-get-gtm-element/3913/1 "2024-04-18T14:45:55Z")

</div>

Hi all,

is there an already usable method to get read the title from a parent cta?  
In Google I used this  
_google\_tag\_manager[“ContainerID”].dataLayer.get(“gtm.element”)_  
to create  
google\_tag\_manager[‘GTM-XXXXXXXX’].dataLayer.get(“gtm.element”).parentElement.parentElement.parentElement.parentElement.parentElement.querySelector(“h2”).innerText

I am using this to get some more information of buttons used on an AD-landingpage. The names of the buttons are always the same so I read the headline of the passage.

For example:

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/piwikpro/original/2X/7/7180f975a95c7510d3254f3afc0c68d673ad038b.png)

Regards Martin

---

<div class="post-metadata">

**Author:** ![asinior](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/asinior/32/1905_2.png) [@asinior](https://community.piwik.pro/u/asinior)\
**Post date:** [April 19, 2024, 9:16am UTC](https://community.piwik.pro/t/a-piwik-method-to-mimik-datalayer-get-gtm-element/3913/2 "2024-04-19T09:16:04Z")

</div>

Hi,  
Piwik PRO creates dataLayer events that have “stg” instead of having “gtm” as the first part before the period, e.g., “stg.pageView”. In general most of these GTM events should have a similar structure to Piwik PRO ones (stg events). In your case we are going to be probably looking at the “stg.click” as this usually contains the “element” value. Here is an example:

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/piwikpro/original/2X/2/2858080a8708816284ec681d1f5e53bb62f673f9.png)

Unfortunately, there is no `dataLayer.get()` method in Piwik PRO, so you would not be able to simply retrieve a value of the dataLayer element by it, but what you could do is:

1. Use vanilla Java script to retrieve the value for element from the stg.click event and create a method that would work similarly to the `dataLayer.get()` method.

2. Use Piwik PRO Tag Manager and create a dataLayer variable that retrieves the value that you would be interested in. The value will be updated with each click and you can use it in your trigger conditions to fire certain tags or simply use the value in your tags (custom event or custom code). Example:
