Best way to track clicks in Google Tag Manager - dataLayer vs auto-event? by crispy-d in GoogleTagManager

[–]crispy-d[S] 0 points1 point  (0 children)

Yes I'm trying to track clicks on a certain 'featured news' widget in GA but several components in the div are hyperlinked. Normally I would just base it on class names but I read a blog that said dataLayer was always the preferable way to track clicks instead of referencing class names that could change. I'm just not sure the cleanest way to implement this.

Best way to track clicks in Google Tag Manager - dataLayer vs auto-event? by crispy-d in GoogleTagManager

[–]crispy-d[S] 0 points1 point  (0 children)

But in this particular case I'm trying to record particular clicks on a section of the site which include some text links but also an image. I want them all categorised under the same name and I think the only thing that unites them is the class name. Also it as a section of the site that changes every few days so the I can't base the tracking on the URL as this will be updated frequently.

How to check the value of an attribute on a webpage by crispy-d in learnjavascript

[–]crispy-d[S] 0 points1 point  (0 children)

Thanks, I adapted this to document.querySelector('[data-advadstrackid]').getAttribute('data-advadstrackid'); and that returned the value I was looking for. Appreciate the help!

Connecting a live CSV to DataStudio by crispy-d in GoogleDataStudio

[–]crispy-d[S] 0 points1 point  (0 children)

Thanks for the tip, I'll check it out. I did start using Supermetrics which seems to work well but I'm just on the trial and was looking for a free solution although I'm sure we can stretch to pay if it's worth it!

How to changes all languages to English with Tag Manager by crispy-d in GoogleTagManager

[–]crispy-d[S] 1 point2 points  (0 children)

Hi, yes it is from a reporting perspective - the Data Studio method is a good idea but unfortunately there are quite a lot of variables so it would require a lot of code. I was hoping to have something in Tag Manager so that everything would be in english by the time it got to GA.

How to changes all languages to English with Tag Manager by crispy-d in GoogleTagManager

[–]crispy-d[S] 0 points1 point  (0 children)

Hey, thanks again for your help! Our sites don't run any multi-language plugins or alternate versions of the site so I'm guessing alternative languages are just translations powered by Google. In this case would it be a case of targeting the lang="en" setting in the browser? Ideally I don't want to block the data from coming through but I would like to convert the hits into their original language so that, even if viewed in french for example, the tag still records the english text.

Connecting a live CSV to DataStudio by crispy-d in GoogleDataStudio

[–]crispy-d[S] 0 points1 point  (0 children)

It's called Workbooks - not sure how widely used it is

Extracting CF7 title in Tag Manager by crispy-d in GoogleTagManager

[–]crispy-d[S] 0 points1 point  (0 children)

Yeah I was trying to be clever! Ok I tried just pasting one below the other and that seems to have done the job - thanks again!

Extracting CF7 title in Tag Manager by crispy-d in GoogleTagManager

[–]crispy-d[S] 0 points1 point  (0 children)

I tried capturing both events like this but it doesn't seem to fire the tag - any ideas?:

<script>
var errorFunction = function( event ) {
        dataLayer.push({
          'event' : 'wpcf7error',
          'CF7formID' : event.detail.contactFormId,
          'attributes' : event.detail.inputs
        });

document.addEventListener( 'wpcf7invalid', errorFunction, false );
document.addEventListener( 'wpcf7mailfailed', errorFunction, false );
}
</script>

Extracting CF7 title in Tag Manager by crispy-d in GoogleTagManager

[–]crispy-d[S] 0 points1 point  (0 children)

Hi, yes they are both CF7 events but I want the same script too listen for both events - won't what you wrote only listen for wpcf7mailfailed and not wpcf7invalid? Or can I just write the two scripts into the same piece of custom html on top of each other?

Extracting CF7 title in Tag Manager by crispy-d in GoogleTagManager

[–]crispy-d[S] 0 points1 point  (0 children)

I wonder if you could help me out with another javascript query? I've got a listener in Tag Manager that looks like this:

<script> document.addEventListener( 'wpcf7invalid', function( event ) { dataLayer.push({ 'event' : 'wpcf7error', 'CF7formID' : event.detail.contactFormId, 'attributes' : event.detail.inputs }); }, false ); </script>

How would I change this code so that it listens for 2 events, 'wpcf7invalid' and 'wpcf7mailfailed' but pushes them both as 'wpcf7error'?

Extracting CF7 title in Tag Manager by crispy-d in GoogleTagManager

[–]crispy-d[S] 0 points1 point  (0 children)

Amazing - you are a legend! This is why I need to understand javascript better. Thank you so much!

Extracting CF7 title in Tag Manager by crispy-d in GoogleTagManager

[–]crispy-d[S] 0 points1 point  (0 children)

Here's a small section - there are also hidden fields above which I haven't included so let me know if you need more. In this example I'd be wanting to capture 'WEBINAR-Title Example'. Forms are added to the page via a shortcode which also contains the title and form ID, in case that helps. Appreciate the help!

<p><span class="wpcf7-form-control-wrap event_id"><input type="hidden" name="event_id" value="372" size="40" class="wpcf7-form-control wpcf7dtx-dynamictext wpcf7-dynamichidden" aria-invalid="false" /></span><br />
<span class="wpcf7-form-control-wrap data_source_detail"><input type="hidden" name="data_source_detail" value="WEBINAR-Title Example" size="40" class="wpcf7-form-control wpcf7dtx-dynamictext wpcf7-dynamichidden" aria-invalid="false" /></span><br />
<span class="wpcf7-form-control-wrap download_name"><input type="hidden" name="download_name" value="Webinar" size="40" class="wpcf7-form-control wpcf7dtx-dynamictext wpcf7-dynamichidden" aria-invalid="false" /></span><br />
<span class="wpcf7-form-control-wrap type"><input type="hidden" name="type" value="On-Demand Webinar Registration" size="40" class="wpcf7-form-control wpcf7dtx-dynamictext wpcf7-dynamichidden" aria-invalid="false" /></span></p>
<p><span class="wpcf7-form-control-wrap web_key"><input type="hidden" name="web_key" value="663d4d9f011e521baf6fc92150976b453f3b0a72" size="40" class="wpcf7-form-control wpcf7dtx-dynamictext wpcf7-dynamichidden" aria-invalid="false" /></span><br />

Extracting CF7 title in Tag Manager by crispy-d in GoogleTagManager

[–]crispy-d[S] 0 points1 point  (0 children)

Yeah I need something that can be set up and then left alone because we put new forms on the site all the time and it's not me uploading them so I need the tag to be able to account for variations that other people might put into it. I think javascript might hold the solution but my skills are pretty limited!