0
votes

I am trying to fire a custom event in Google Tag Manager for a Virtual Page View. I want to be able to track a conversion in a dynamic shopping cart page where the actual URL does not change.

I added the following code for a dataLayer and set it up to fire when the event= VirtualPageView but it's not working.

Any ideas?

dataLayer.push({
  'event':'VirtualPageView',
  'virtualPageURL':'/thankyou',
  'virtualPageTitle':'Thank You'
  'conversionValue':'value'
  'currencyCode':'currency'
});

Google Tag Setup Custom Event Setup

1
What error messages are you seeing? How are you determining that it's not working? - nyuen
When I debug with GTM, it states that it's not firing when I do a test conversion. There are other tags firing on the page (UA, Remarketing) but those fire sitewide. - Kate McGrath
Please include screenshots of your tag you're trying to fire, and the trigger used to fire that tag. Also, please confirm, you said the dataLayer code you posted is set to fire when event = VirtualPageView? - nyuen
Yes, when the event = "VirtualPageView". - Kate McGrath
Sorry, I mean, you said "added the following code for a dataLayer and set it up to fire when ....". So what's set to fire when event = VirtualPageView? Also, please post screenshots. - nyuen

1 Answers

0
votes

Looking at your code I see a lot of missing commas after everything but the second line. This will cause the JS to fail which means no event is pushed into the dataLayer which means GTM won't see anything happening and therefore not fire any tags.

I.e. add a comma after 'virtualPageTitle':'Thank You and after 'conversionValue':'value'. Keep in mind that if you actually pass 'value' as a string and an AdWords Conversion Tag looks for a float, it will fail that tag.

GTM is fairly finicky and will just stop execution when JS code related to it fails.