AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
4.5K members online now
4.5K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Pulling data from page data source into Google Analytics

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

My company started to encrypt in URL the info on the utm campaigns parameters,

it resulted that I cannot see the data on the performance on the campaigns in GA campaign reporting.

The data on the utm campaigns is present in the page source for instance:

campaign: {"campaignGroup":"28","utm_source":"ABC","campaign_code":"zcj4i","utm_campaign":"Affiliate","utm_term":"XYZ","transactionId":"123}

 

Is it a way to pull the utm into GA from the page source? 

Should I set up it as a Custom Variable?

 

Re: Pulling data from page data source into Google Analytics

Follower ✭ ☆ ☆
# 2
Follower ✭ ☆ ☆

Hi Anna,

 

There are a couple of ways to approach this problem depending on the tools you have available to you. I will summarize the approach using Universal Analytics (UA) on page code, or Google Tag Manager (GTM). If any of my replies are unclear, let me know.

 

UA on page code:

If you are using on page code for universal analytics, after the UA tracking snippet, you could use the following methods to manually set the campaign tracking parameters before firing off a pageview:

 

ga('create', 'UA-XXXXXXX-X', 'auto');
ga('set', {
  campaignName: 'someName',
  campaignSource: 'someSource',
  campaignMedium: 'someMedium',
  campaignKeyword: 'someKeyword',
  campaignContent: 'someContent'
});
ga('send', 'pageview');

 

 

GTM

This approach is easier as you can simply use the "Fields to set" option in the Pageview tag you configured within GTM. Within each field you would input the variable you created for capturing the campaign parameters from your page data. Here is a screenshot of what this would look like:

Screenshot_1.png

 

Hope this helps, let me know if you have any other questions!

 

Cheers,

 

Bogdan

 

Re: Pulling data from page data source into Google Analytics

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Many thanks Bogdan for your recommendation.
We have implemented Uninversal Analytics code across our websites.
May you please confirm if I understand correctly and the code in my case should be as follow:
ga('create', 'UA-XXXXXXX-X', 'auto'); ga('set', { campaignName: 'someName', campaignSource: 'someSource', campaignMedium: 'someMedium', campaignKeyword: 'someKeyword', campaignContent: 'someContent' }); ga('send', 'pageview');

Cheers,
Anna

Re: Pulling data from page data source into Google Analytics

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Sorry the code should be:

ga('set', { campaignName: 'campaignGroup',
campaignSource: 'utm_source',
campaignMedium: 'utm_campaign',
campaignKeyword: 'utm_term',
campaignContent: 'transactionID' });

Re: Pulling data from page data source into Google Analytics

Follower ✭ ☆ ☆
# 5
Follower ✭ ☆ ☆

Hi Anna,

 

The complete code to send a pageview into Google Analytics using campaign parameters found in the page attributes would be as follows:

 

 

ga('create', 'UA-XXXXXXX-X', 'auto');
ga('set', {
  campaignName: 'someName',
  campaignSource: 'someSource',
  campaignMedium: 'someMedium',
  campaignKeyword: 'someKeyword',
  campaignContent: 'someContent'
});
ga('send', 'pageview');

 

Where

  • UA-XXXXXXX-Y is your property tracking id
  • 'someName' is the name of the campaign you are pulling from the page attributes
  • 'someSource' is the source of the campaign you are pulling from the page attributes
  • 'someMedium' is the medium of the campaign you are pulling from the page attributes
  • 'someKeyword' is the keyword of the campaign you are pulling from the page attributes
  • 'someContent' is the content of the campaign you are pulling from the page attributes

 

Without being able to view your specific website, I can't tell you exactly how you would pull the information out of the page attributes which is why I've used placeholder values in my example. If the page attributes is a JSON object, you could try the following (again, can't be 100% sure):

 

ga('set', { 
campaignName: campaign.campaignGroup,
campaignSource: campaign.utm_source,
campaignMedium: campaign.utm_campaign,
campaignKeyword: campaign.utm_term,
campaignContent: campaign.transactionID
});

Let me know how it goes!

 

Cheers,

 

Bogdan

 

 

 

 

Re: Pulling data from page data source into Google Analytics

[ Edited ]
Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi Bogdan,
Thank you very much for your help. May you please have a look at the website by following this link; http://dt51.net/c/?wi=22848&si=8713&li=1463216&ws=DCDIN&dl=
I would like to pull back to GA following info on the campaign from page source:
campaign: {"campaignGroup":"22848","utm_source":"Daisycon","campaign_code":"zcj4ieu0jqx3j98","locale":"sv_SE","utm_campaign":"Affiliate Email","utm_term":"AFF","transactionId":"DCDIN"}
Hope this clarification helps to find out an optimal approach.
Once again many thanks for your recommendation.
Cheers,
Anna

 

<edited by a Community Manager as noted below>
 
NOTE: This post has been edited by a Community Manager - per Community Guidelines - in order to remove contact information which was most likely due to an email or mobile footer. This is done in order to protect account security and/or privacy. Please be sure to remove this information in future replies. Thank you for your understanding.

Re: Pulling data from page data source into Google Analytics

Follower ✭ ☆ ☆
# 7
Follower ✭ ☆ ☆

Anna,

 

Thank you for providing the link to your webpage! Your Google Analytics on-page code would look like this:

 

ga('create', 'UA-XXXXXX-Y', 'auto');
ga('set', { 
    campaignName: window.corona.campaign.campaignGroup,
    campaignSource: window.corona.campaign.utm_source,
    campaignMedium: window.corona.campaign.utm_campaign,
    campaignKeyword: window.corona.campaign.utm_term,
    campaignContent: window.corona.campaign.transactionID
});
ga('send', 'pageview');

Just make sure to replace UA-XXXXXX-Y with the correct tracking ID and you should be good to go!

 

Cheers,

 

Bogdan

Re: Pulling data from page data source into Google Analytics

[ Edited ]
Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭

[Research Now]











Anna B

<edited by a Community Manager as noted below>
 
NOTE: This post has been edited by a Community Manager - per Community Guidelines - in order to remove contact information which was most likely due to an email or mobile footer. This is done in order to protect account security and/or privacy. Please be sure to remove this information in future replies. Thank you for your understanding.

Re: Pulling data from page data source into Google Analytics

Follower ✭ ☆ ☆
# 9
Follower ✭ ☆ ☆
Hi Anna,

I don't think your last reply came through.

Let me know if the solution worked!

Cheers,

Bogdan

Re: Pulling data from page data source into Google Analytics

[ Edited ]
Visitor ✭ ✭ ✭
# 10
Visitor ✭ ✭ ✭

Hi Bogdan,
Once again thank you for your help. It all looks very good, I will test the code provided and let you know how it goes.
Have a great weekend!
Cheers,
Anna

<edited by a Community Manager as noted below>
 
NOTE: This post has been edited by a Community Manager - per Community Guidelines - in order to remove contact information which was most likely due to an email or mobile footer. This is done in order to protect account security and/or privacy. Please be sure to remove this information in future replies. Thank you for your understanding.