Adding a Google Analytics tag to a page load rule in DTM

Avatar

Avatar
Level 1
mcbutterfant
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
mcbutterfant
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
View profile
mcbutterfant
Level 1

08-05-2018

Hi All,

I've been asked to insert a Google Analytics tag to a page load rule in DTM.  I've implemented it in the normal fashion (sequential javascript), however, I need the tag to be populated with data by pulling in the data from data elements.

I've used the following formats and nothing seems to work:

* %data_element%

* _satellite.getVar('data_element')

* _satellite.getDateElement('data_element')

Our partners checked their Google Analytics instance and for the top option they are seeing %data_element% rather than the actual data.  For the other two formats they received no transaction data at all.

Attached is an image of the code (identifiable names changed), the three items in red are the objects that I want to be populated by data elements.

Any help would be greatly appreciated!

Thanks

Matt

Google Analytics tag.jpg

Replies

Avatar

Avatar
Boost 5
Level 4
nikitaf2673776
Level 4

Likes

37 likes

Total Posts

70 posts

Correct reply

32 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile

Avatar
Boost 5
Level 4
nikitaf2673776
Level 4

Likes

37 likes

Total Posts

70 posts

Correct reply

32 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile
nikitaf2673776
Level 4

08-05-2018

When you're setting the Insurer, product type and name in the GA tag are you surrounding the data elements by quotes?

i.e. are you doing this      ga('gcg.set','dimension70,"%data_element%");

or are you doing this       ga('gcg.set','dimension70,%data_element%);

you should be doing the second one  

Avatar

Avatar
Level 1
mcbutterfant
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
mcbutterfant
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
View profile
mcbutterfant
Level 1

09-05-2018

Hi nikitarama,

I've tried both ways.  The second option without the quotes brings up an error in DTM:

error s.s.jpg

Avatar

Avatar
Boost 5
Level 4
nikitaf2673776
Level 4

Likes

37 likes

Total Posts

70 posts

Correct reply

32 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile

Avatar
Boost 5
Level 4
nikitaf2673776
Level 4

Likes

37 likes

Total Posts

70 posts

Correct reply

32 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile
nikitaf2673776
Level 4

09-05-2018

Try something along these lines:

var insurer = _satellite.getVar('data_element');

then later...

ga('gcg.set','dimension70, insurer);

Edit: Check your data elements, are they javascript elements? Do they have a path that is different from their name?

Edit2: Are the data elements properly set up? Go to the page, open the dev console and enter _satellite.getVar('data_element'); Does the value you're expecting come up?

Avatar

Avatar
Give Back
Employee
DeepakKar
Employee

Likes

2 likes

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Give Back
Boost 1
View profile

Avatar
Give Back
Employee
DeepakKar
Employee

Likes

2 likes

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Give Back
Boost 1
View profile
DeepakKar
Employee

09-05-2018

Within custom code, you should use _satellite.getVar('data element name') to access the data element value.

I would recommend you first validate the data element value in browser console and proceed from there. Improper set up or timing issues could be resulting in empty data element at access time.

Avatar

Avatar
Level 1
mcbutterfant
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
mcbutterfant
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
View profile
mcbutterfant
Level 1

14-05-2018

Hi DeepakKar

After testing this method works but intermittently.  Our partner can see data populating for one test transaction but nothing for the rest of the transactions. 

Could this be due to a timing issue?

Thanks

Matt

Avatar

Avatar
Give Back 10
Level 4
Rydal_Williams
Level 4

Likes

22 likes

Total Posts

72 posts

Correct reply

23 solutions
Top badges earned
Give Back 10
Give Back 5
Give Back 3
Give Back
Boost 5
View profile

Avatar
Give Back 10
Level 4
Rydal_Williams
Level 4

Likes

22 likes

Total Posts

72 posts

Correct reply

23 solutions
Top badges earned
Give Back 10
Give Back 5
Give Back 3
Give Back
Boost 5
View profile
Rydal_Williams
Level 4

17-05-2018

Probably a timing issue, is the data element pulling data from a data layer object on the page that is updated via ajax?